qbtrade/pkg/service/persistence_facade.go
2024-06-27 22:42:38 +08:00

22 lines
452 B
Go

package service
type PersistenceServiceFacade struct {
Redis *RedisPersistenceService
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
}