mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
bbgo: add persistence Sync api
This commit is contained in:
parent
f3691489dd
commit
82c7c024ce
|
@ -76,6 +76,16 @@ func (p *Persistence) Save(val interface{}, subIDs ...string) error {
|
|||
return store.Save(val)
|
||||
}
|
||||
|
||||
func (p *Persistence) Sync(obj interface{}) error {
|
||||
id := callID(obj)
|
||||
if len(id) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
ps := p.Facade.Get()
|
||||
return storePersistenceFields(obj, id, ps)
|
||||
}
|
||||
|
||||
type StructFieldIterator func(tag string, ft reflect.StructField, fv reflect.Value) error
|
||||
|
||||
func iterateFieldsByTag(obj interface{}, tagName string, cb StructFieldIterator) error {
|
||||
|
|
|
@ -266,11 +266,12 @@ func (s *Strategy) Suspend(ctx context.Context) error {
|
|||
log.WithError(err).Errorf("graceful cancel order error")
|
||||
s.Notify("graceful cancel order error")
|
||||
} else {
|
||||
s.Notify("All orders cancelled.")
|
||||
s.Notify("All orders are cancelled.")
|
||||
}
|
||||
|
||||
s.tradeCollector.Process()
|
||||
return nil
|
||||
|
||||
return s.Persistence.Sync(s)
|
||||
}
|
||||
|
||||
func (s *Strategy) Resume(ctx context.Context) error {
|
||||
|
|
Loading…
Reference in New Issue
Block a user