Files
gocryptotrader/engine/subsystem_types.go
Ryan O'Hara-Reid d636049fb2 exchanges: Initial context propagation (#744)
* gct: phase one context awareness pass

* exchanges: context propagation pass

* common/requester: force context requirement

* gctcli/exchanges: linter fix

* rpcserver: fix test using dummy rpc server

* backtester: fix comments

* grpc: add correct cancel and timeout for commands

* rpcserver_test: add comment on dummy server

* common: deprecated SendHTTPGetRequest

* linter: fix

* linter: turn on no context check

* apichecker: fix context linter issue

* binance: use param context

* common: remove checks as this gets executed before main

* common: change mutex to RW as clients can be used by multiple go routines.

* common: remove init and JIT default client. Unexport global variables and add protection.

* common: Add comments

* bithumb: after dinner mints fix
2021-09-11 13:52:07 +10:00

87 lines
3.2 KiB
Go

package engine
import (
"context"
"errors"
"github.com/thrasher-corp/gocryptotrader/communications/base"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/database"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/portfolio"
)
const (
// MsgSubSystemStarting message to return when subsystem is starting up
MsgSubSystemStarting = "starting..."
// MsgSubSystemStarted message to return when subsystem has started
MsgSubSystemStarted = "started."
// MsgSubSystemShuttingDown message to return when a subsystem is shutting down
MsgSubSystemShuttingDown = "shutting down..."
// MsgSubSystemShutdown message to return when a subsystem has shutdown
MsgSubSystemShutdown = "shutdown."
)
var (
// ErrSubSystemAlreadyStarted message to return when a subsystem is already started
ErrSubSystemAlreadyStarted = errors.New("subsystem already started")
// ErrSubSystemNotStarted message to return when subsystem not started
ErrSubSystemNotStarted = errors.New("subsystem not started")
// ErrNilSubsystem is returned when a subsystem hasn't had its Setup() func run
ErrNilSubsystem = errors.New("subsystem not setup")
errNilWaitGroup = errors.New("nil wait group received")
errNilExchangeManager = errors.New("cannot start with nil exchange manager")
errNilDatabaseConnectionManager = errors.New("cannot start with nil database connection manager")
errNilConfig = errors.New("received nil config")
)
// iExchangeManager limits exposure of accessible functions to exchange manager
// so that subsystems can use some functionality
type iExchangeManager interface {
GetExchanges() []exchange.IBotExchange
GetExchangeByName(string) (exchange.IBotExchange, error)
}
// iCommsManager limits exposure of accessible functions to communication manager
type iCommsManager interface {
PushEvent(evt base.Event)
}
// iOrderManager defines a limited scoped order manager
type iOrderManager interface {
Exists(*order.Detail) bool
Add(*order.Detail) error
Cancel(context.Context, *order.Cancel) error
GetByExchangeAndID(string, string) (*order.Detail, error)
UpdateExistingOrder(*order.Detail) error
}
// iPortfolioManager limits exposure of accessible functions to portfolio manager
type iPortfolioManager interface {
GetPortfolioSummary() portfolio.Summary
IsWhiteListed(string) bool
IsExchangeSupported(string, string) bool
}
// iBot limits exposure of accessible functions to engine bot
type iBot interface {
SetupExchanges() error
}
// iCurrencyPairSyncer defines a limited scoped currency pair syncer
type iCurrencyPairSyncer interface {
IsRunning() bool
PrintTickerSummary(*ticker.Price, string, error)
PrintOrderbookSummary(*orderbook.Base, string, error)
Update(string, currency.Pair, asset.Item, int, error) error
}
// iDatabaseConnectionManager defines a limited scoped databaseConnectionManager
type iDatabaseConnectionManager interface {
GetInstance() database.IDatabase
}