mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
add Get method to the persistence service facade
This commit is contained in:
parent
21b092037e
commit
a8516edb98
|
@ -536,12 +536,6 @@ func getSessionSymbols(session *ExchangeSession, defaultSymbols ...string) ([]st
|
|||
}
|
||||
|
||||
func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) error {
|
||||
// Configure persistence service, by default we will use memory service
|
||||
var persistence service.PersistenceService = environ.PersistenceServiceFacade.Memory
|
||||
if environ.PersistenceServiceFacade.Redis != nil {
|
||||
persistence = environ.PersistenceServiceFacade.Redis
|
||||
}
|
||||
|
||||
environ.Notifiability = Notifiability{
|
||||
SymbolChannelRouter: NewPatternChannelRouter(nil),
|
||||
SessionChannelRouter: NewPatternChannelRouter(nil),
|
||||
|
@ -562,6 +556,7 @@ func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) erro
|
|||
}
|
||||
}
|
||||
|
||||
persistence := environ.PersistenceServiceFacade.Get()
|
||||
telegramBotToken := viper.GetString("telegram-bot-token")
|
||||
if len(telegramBotToken) > 0 {
|
||||
tt := strings.Split(telegramBotToken, ":")
|
||||
|
|
|
@ -5,3 +5,17 @@ type PersistenceServiceFacade struct {
|
|||
Json *JsonPersistenceService
|
||||
Memory *MemoryService
|
||||
}
|
||||
|
||||
// Get returns the preferred persistence service by fallbacks
|
||||
// Redis will be preferred at the first position.
|
||||
func (facade *PersistenceServiceFacade) Get() PersistenceService {
|
||||
if facade.Redis != nil {
|
||||
return facade.Redis
|
||||
}
|
||||
|
||||
if facade.Json != nil {
|
||||
return facade.Json
|
||||
}
|
||||
|
||||
return facade.Memory
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user