bbgo: configure persistence facade into the isolation context

This commit is contained in:
c9s 2022-10-05 18:48:12 +08:00
parent 673304bcf1
commit e92219194f
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 6 additions and 3 deletions

View File

@ -15,7 +15,7 @@ func BootstrapEnvironmentLightweight(ctx context.Context, environ *Environment,
} }
if userConfig.Persistence != nil { if userConfig.Persistence != nil {
if err := ConfigurePersistence(userConfig.Persistence); err != nil { if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil {
return errors.Wrap(err, "persistence configure error") return errors.Wrap(err, "persistence configure error")
} }
} }
@ -33,7 +33,7 @@ func BootstrapEnvironment(ctx context.Context, environ *Environment, userConfig
} }
if userConfig.Persistence != nil { if userConfig.Persistence != nil {
if err := ConfigurePersistence(userConfig.Persistence); err != nil { if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil {
return errors.Wrap(err, "persistence configure error") return errors.Wrap(err, "persistence configure error")
} }
} }

View File

@ -102,12 +102,15 @@ func NewPersistenceServiceFacade(conf *PersistenceConfig) (*service.PersistenceS
return facade, nil return facade, nil
} }
func ConfigurePersistence(conf *PersistenceConfig) error { func ConfigurePersistence(ctx context.Context, conf *PersistenceConfig) error {
facade, err := NewPersistenceServiceFacade(conf) facade, err := NewPersistenceServiceFacade(conf)
if err != nil { if err != nil {
return err return err
} }
isolation := GetIsolationFromContext(ctx)
isolation.persistenceServiceFacade = facade
persistenceServiceFacade = facade persistenceServiceFacade = facade
return nil return nil
} }