Documentation ¶
Index ¶
Constants ¶
const ( ALPHA_VANTAGE_ENV_VAR_NAME = "ALPHAVANTAGE_KEY" LOGS_PATH_ENV_VAR_NAME = "SENTINEL_LOGS_PATH" NATS_STOCKS_VAR_NAME = "NATS_STOCKS_DATA_URI" NATS_STOCKS_CLUSTERID_VAR_NAME = "NATS_STOCKS_CLUSTERID" DEFAULT_LOGS_PATH = "./logs" )
const (
NATS_STOCKS_SUBJECT = "stocks"
)
Variables ¶
var ( ErrAlphaVantageKeyNotDefined = errors.New("It was impossible to load AlphaVantageKey env var") ErrStocksNATSKeyNotDefined = errors.New("It was impossible to load Stocks NATS URI env var") ErrStocksNATSClusterIDKeyNotDefined = errors.New("It was impossible to load Stocks NATS Cluster ID env var") )
Functions ¶
Types ¶
type AppContext ¶
type AppContext struct {
// contains filtered or unexported fields
}
AppContext represents a general context for the application
func NewAppContext ¶
func NewAppContext(config *SentinelConfig) (ctx *AppContext, err error)
NewAppContext knows how to instantiate Sentinels General Context TODO add some logging TODO add tests
func (*AppContext) Logger ¶
func (ac *AppContext) Logger() *zap.Logger
Logger returns application default logger
func (*AppContext) SentinelConfig ¶
func (ac *AppContext) SentinelConfig() *SentinelConfig
SentinelConfig returns Sentinel config
func (*AppContext) StockNats ¶
func (ac *AppContext) StockNats() client.NATSServer
StockNats returns Nats server connection
type Context ¶
type Context interface { SentinelConfig() *SentinelConfig StockNats() client.NATSServer Logger() *zap.Logger }
type Schedule ¶
func NewSchedule ¶
type Sentinel ¶
type Sentinel interface { // Id returns an unique identifier to the sentinel Id() string // Run puts sentinel to run and returns its execution Id and an error Run(stockProvider client.StockProvider) (string, error) }
type SentinelConfig ¶
type SentinelConfig struct { AlphaVantageKey string LogsPath string NATSStocksURI string NATSStocksClusterID string }
SentinelConfig stores the general configuration directives for a Sentinel to run
func NewSentinelConfig ¶
func NewSentinelConfig() (config *SentinelConfig, err error)
NewSentinelConfig creates an instance of Sentinel Config, loading all data necessary to run a Sentinel TODO add tests
type SentinelDock ¶
type SentinelDock struct {
// contains filtered or unexported fields
}
SentinelDock knows when to launch new sentinels by watching a event stream
func NewSentinelDock ¶
func NewSentinelDock(ctx Context) *SentinelDock
NewSentinelDock provides a working SentinelDock to a given app context TODO add tests
func (*SentinelDock) GetId ¶
func (sd *SentinelDock) GetId() string
Id returns dock id (or execution id, if you prefer)
func (*SentinelDock) Watch ¶
func (sd *SentinelDock) Watch() (err error)
Watch observes a queue in order to know when launch new Sentinels TODO add tests
type StockSentinel ¶
type StockSentinel struct {
// contains filtered or unexported fields
}
func NewStockSentinel ¶
func NewStockSentinel(ctx Context, schedule *Schedule) (sentinel *StockSentinel, err error)
NewSentinel is a base Sentinel build
func (*StockSentinel) Id ¶
func (s *StockSentinel) Id() string
Id returns a unique identifier to the sentinel
func (*StockSentinel) Run ¶
func (s *StockSentinel) Run(stockProvider client.StockProvider) (string, error)
Id returns a unique identifier to the sentinel