mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
Merge pull request #1075 from c9s/bhwu/add-persistence-to-env
FEATURE: add persistence service to environment
This commit is contained in:
commit
8039068d51
|
@ -19,7 +19,7 @@ func BootstrapEnvironmentLightweight(ctx context.Context, environ *Environment,
|
|||
}
|
||||
|
||||
if userConfig.Persistence != nil {
|
||||
if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil {
|
||||
if err := ConfigurePersistence(ctx, environ, userConfig.Persistence); err != nil {
|
||||
return errors.Wrap(err, "persistence configure error")
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func BootstrapEnvironment(ctx context.Context, environ *Environment, userConfig
|
|||
}
|
||||
|
||||
if userConfig.Persistence != nil {
|
||||
if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil {
|
||||
if err := ConfigurePersistence(ctx, environ, userConfig.Persistence); err != nil {
|
||||
return errors.Wrap(err, "persistence configure error")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ type Environment struct {
|
|||
AccountService *service.AccountService
|
||||
WithdrawService *service.WithdrawService
|
||||
DepositService *service.DepositService
|
||||
PersistentService *service.PersistenceServiceFacade
|
||||
|
||||
// startTime is the time of start point (which is used in the backtest)
|
||||
startTime time.Time
|
||||
|
|
|
@ -102,7 +102,7 @@ func NewPersistenceServiceFacade(conf *PersistenceConfig) (*service.PersistenceS
|
|||
return facade, nil
|
||||
}
|
||||
|
||||
func ConfigurePersistence(ctx context.Context, conf *PersistenceConfig) error {
|
||||
func ConfigurePersistence(ctx context.Context, environ *Environment, conf *PersistenceConfig) error {
|
||||
facade, err := NewPersistenceServiceFacade(conf)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -112,5 +112,6 @@ func ConfigurePersistence(ctx context.Context, conf *PersistenceConfig) error {
|
|||
isolation.persistenceServiceFacade = facade
|
||||
|
||||
persistenceServiceFacade = facade
|
||||
environ.PersistentService = facade
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user