tacitus: some refactoring

This commit is contained in:
Kevin Cotugno 2017-09-27 20:38:25 -07:00
parent f227f7f79b
commit 7f7ce5013d
3 changed files with 21 additions and 4 deletions

8
database_client.go Normal file
View File

@ -0,0 +1,8 @@
package tacitus
type DatabaseClientService interface {
Open() error
Close() error
TradeService() TradeService
SetLogger(logger Logger)
}

View File

@ -2,9 +2,11 @@ package tacitus
type ListenerService interface {
Open() error
Close()
Subscribe(product string)
Close() error
Subscribe(products ...string)
Stream() <-chan Trade
Error() <-chan error
SendErrors() bool
SetSendErrors(send bool)
SetLogger(logger Logger)
}

View File

@ -21,15 +21,22 @@ type Trade struct {
}
type TradeService interface {
Trade(id int) (Trade, error)
TradeByTradeId(id int, prod string) (Trade, error)
CreateTrade(t Trade) (Trade, error)
DeleteTrade(id int)
Trade(id int) (Trade, error)
TradeByTradeId(id int, prod string) (Trade, error)
TradesInDateRange(product string, start, end time.Time) ([]Trade, error)
FirstTrades(product string, limit int) ([]Trade, error)
LastTrades(product string, limit int) ([]Trade, error)
TradesAfter(product string, id, limit int) ([]Trade, error)
TradesBefore(product string, id, limit int) ([]Trade, error)
TradesAfterAll(product string, id int) error
Next() (Trade, error)
Done() bool
CloseRows() error
}
func ValidProduct(prod string) bool {