From e29d9af9c817bc6df92d15e54596281796ebf140 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 2 May 2021 18:16:34 +0800 Subject: [PATCH] fix persistence config unmarshalling --- go.sum | 1 + pkg/bbgo/testdata/persistence.yaml | 1 + pkg/service/persistence.go | 11 +++++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.sum b/go.sum index 905d78bc4..b35e75d8c 100644 --- a/go.sum +++ b/go.sum @@ -360,6 +360,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= diff --git a/pkg/bbgo/testdata/persistence.yaml b/pkg/bbgo/testdata/persistence.yaml index 457303b33..f418b55f9 100644 --- a/pkg/bbgo/testdata/persistence.yaml +++ b/pkg/bbgo/testdata/persistence.yaml @@ -19,6 +19,7 @@ persistence: database: "persistence" strategies: +- on: max swing: symbolPosition: persistence: diff --git a/pkg/service/persistence.go b/pkg/service/persistence.go index ef55ca2ef..e8cb47c35 100644 --- a/pkg/service/persistence.go +++ b/pkg/service/persistence.go @@ -11,13 +11,12 @@ type Store interface { } type RedisPersistenceConfig struct { - Host string `json:"host" env:"REDIS_HOST"` - Port string `json:"port" env:"REDIS_PORT"` - Password string `json:"password" env:"REDIS_PASSWORD"` - DB int `json:"db" env:"REDIS_DB"` + 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"` } type JsonPersistenceConfig struct { - Directory string `json:"directory"` + Directory string `yaml:"directory" json:"directory"` } -