dbstore

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBStore

type DBStore struct {
	// contains filtered or unexported fields
}

func LoadDB

func LoadDB(cfg *viper.Viper) (db *DBStore, err error)

Load init db from config file

func NewDBStore

func NewDBStore(dbType, dbURI string) (dr *DBStore, err error)

NewDBStore support sqlite,mysql,pg

func (*DBStore) Close

func (dr *DBStore) Close() (err error)

Close close db

func (*DBStore) GetKlineTables

func (dr *DBStore) GetKlineTables() (tbls []TableInfo, err error)

func (*DBStore) GetKlineTbl

func (dr *DBStore) GetKlineTbl(exchange, symbol, binSize string) *KlineTbl

GetKlineTbl get kline table

func (*DBStore) GetTableSession

func (dr *DBStore) GetTableSession(tbl string, data TimeData) (sess *xorm.Session)

GetTableSession get table,if not exsit, create the table

func (*DBStore) GetTables

func (dr *DBStore) GetTables() (tbls []string, err error)

func (*DBStore) NewKlineTbl added in v0.0.5

func (dr *DBStore) NewKlineTbl(exchange, symbol, binSize string) *KlineTbl

func (*DBStore) SetDebug

func (dr *DBStore) SetDebug(bDebug bool)

SetDebug set debug mode

func (*DBStore) SetUseCache added in v0.0.5

func (d *DBStore) SetUseCache(useCache bool)

func (*DBStore) WriteKlines

func (d *DBStore) WriteKlines(exchange, symbol, binSize string, datas []interface{}) (err error)

WriteKlines write klines

type DataCreator

type DataCreator interface {
	Sing() TimeData
	Slice() interface{}
	GetSlice(interface{}) []interface{}
}

type KlineTbl

type KlineTbl struct {
	BaseProcesser
	TimeTbl
	// contains filtered or unexported fields
}

KlineTbl kline data table

func NewKlineTbl

func NewKlineTbl(db *DBStore, exchange, symbol, binSize string) (t *KlineTbl)

func (*KlineTbl) GetSlice

func (tbl *KlineTbl) GetSlice(data interface{}) (rets []interface{})

func (*KlineTbl) Init

func (tbl *KlineTbl) Init(bus *Bus) (err error)

func (*KlineTbl) SetLoadDataMode

func (tbl *KlineTbl) SetLoadDataMode(bLoad bool)

func (*KlineTbl) Sing

func (tbl *KlineTbl) Sing() TimeData

func (*KlineTbl) Slice

func (tbl *KlineTbl) Slice() interface{}

type TableInfo

type TableInfo struct {
	Exchange string
	Symbol   string
	BinSize  string
}

type TimeData

type TimeData interface {
	GetStart() int64
	Time() time.Time
	GetTable() string
	SetTable(string)
}

TimeData data with time info

type TimeTbl

type TimeTbl struct {
	// contains filtered or unexported fields
}

TimeTbl tbl with time info

func NewTimeTbl

func NewTimeTbl(db *DBStore, creator DataCreator, exchange, symbol, binSize, extName string) (t *TimeTbl)

NewTimeTbl create new time table

func (*TimeTbl) AddOrUpdateData

func (t *TimeTbl) AddOrUpdateData(data interface{}) (err error)

func (*TimeTbl) CacheData added in v0.0.6

func (t *TimeTbl) CacheData(start, end time.Time, bSize string) (err error)

CacheData load datas and store to cache

func (*TimeTbl) Count

func (tbl *TimeTbl) Count() (n int64, err error)

func (*TimeTbl) DataChan

func (t *TimeTbl) DataChan(start, end time.Time, bSize string) (klines chan []interface{}, err error)

func (*TimeTbl) DataRecent

func (t *TimeTbl) DataRecent(recent int32, bSize string) (klines []interface{}, err error)

func (*TimeTbl) Exists

func (t *TimeTbl) Exists(data interface{}) (bRet bool, err error)

Exists check if data's time exists

func (*TimeTbl) GetDatas

func (t *TimeTbl) GetDatas(since, end time.Time, limit int) (datas []interface{}, err error)

func (*TimeTbl) GetNewest

func (tbl *TimeTbl) GetNewest() (t time.Time)

func (*TimeTbl) GetOldest

func (tbl *TimeTbl) GetOldest() (t time.Time)

func (*TimeTbl) GetSymbol

func (t *TimeTbl) GetSymbol() string

func (*TimeTbl) GetTable

func (t *TimeTbl) GetTable() string

func (*TimeTbl) IsEmpty

func (tbl *TimeTbl) IsEmpty() (isEmpty bool)

func (*TimeTbl) SetCloseCh

func (t *TimeTbl) SetCloseCh(closeCh chan bool)

func (*TimeTbl) SetLoadOnce added in v0.0.5

func (t *TimeTbl) SetLoadOnce(loadOnce int)

func (*TimeTbl) UpdateData

func (t *TimeTbl) UpdateData(data interface{}) (err error)

UpdateData update datas

func (*TimeTbl) WriteData

func (t *TimeTbl) WriteData(data interface{}) (err error)

WriteData write data

func (*TimeTbl) WriteDatas

func (t *TimeTbl) WriteDatas(datas []interface{}) (err error)

WriteDatas write datas

type TradeTbl

type TradeTbl struct {
}

func NewTradeTbl

func NewTradeTbl(db *DBStore, id int64) (t *TradeTbl)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL