From 7f7ce5013d430ff6af0865d6b61938cc716d6a95 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Wed, 27 Sep 2017 20:38:25 -0700 Subject: [PATCH] tacitus: some refactoring --- database_client.go | 8 ++++++++ listener.go | 6 ++++-- trade.go | 11 +++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 database_client.go diff --git a/database_client.go b/database_client.go new file mode 100644 index 0000000..74c76e2 --- /dev/null +++ b/database_client.go @@ -0,0 +1,8 @@ +package tacitus + +type DatabaseClientService interface { + Open() error + Close() error + TradeService() TradeService + SetLogger(logger Logger) +} diff --git a/listener.go b/listener.go index b2bdb55..bc2bc50 100644 --- a/listener.go +++ b/listener.go @@ -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) } diff --git a/trade.go b/trade.go index 69254d6..de43055 100644 --- a/trade.go +++ b/trade.go @@ -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 {