bbgo_origin/pkg/service/persistence.go

38 lines
947 B
Go
Raw Normal View History

2021-02-20 17:01:39 +00:00
package service
import (
"time"
"github.com/go-redis/redis/v8"
)
2023-03-03 07:42:29 +00:00
2021-02-20 17:01:39 +00:00
type PersistenceService interface {
NewStore(id string, subIDs ...string) Store
}
type Store interface {
Load(val interface{}) error
Save(val interface{}) error
Reset() error
}
2023-03-03 07:42:29 +00:00
type Expirable interface {
Expiration() time.Duration
}
2021-02-20 17:01:39 +00:00
type RedisPersistenceConfig struct {
2023-01-05 11:07:15 +00:00
Host string `yaml:"host" json:"host" env:"REDIS_HOST"`
Port string `yaml:"port" json:"port" env:"REDIS_PORT"`
Password string `yaml:"password,omitempty" json:"password,omitempty" env:"REDIS_PASSWORD"`
DB int `yaml:"db" json:"db" env:"REDIS_DB"`
Namespace string `yaml:"namespace" json:"namespace" env:"REDIS_NAMESPACE"`
// Redis is the redis client field
// this field is optional, only used when you want to set the redis client instance in the runtime
Redis *redis.Client
2021-02-20 17:01:39 +00:00
}
type JsonPersistenceConfig struct {
2021-05-02 10:16:34 +00:00
Directory string `yaml:"directory" json:"directory"`
2023-05-25 06:01:22 +00:00
}