Merge pull request #1365 from bailantaotao/edwin/make-jump-to-option-2

FEATURE: [batch] add jumpIfEmpty opts to closed order batch query
This commit is contained in:
bailantaotao 2023-10-26 11:22:29 +08:00 committed by GitHub
commit 8ddb31b339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@ type ClosedOrderBatchQuery struct {
types.ExchangeTradeHistoryService types.ExchangeTradeHistoryService
} }
func (q *ClosedOrderBatchQuery) Query(ctx context.Context, symbol string, startTime, endTime time.Time, lastOrderID uint64) (c chan types.Order, errC chan error) { func (q *ClosedOrderBatchQuery) Query(ctx context.Context, symbol string, startTime, endTime time.Time, lastOrderID uint64, opts ...Option) (c chan types.Order, errC chan error) {
query := &AsyncTimeRangedBatchQuery{ query := &AsyncTimeRangedBatchQuery{
Type: types.Order{}, Type: types.Order{},
Q: func(startTime, endTime time.Time) (interface{}, error) { Q: func(startTime, endTime time.Time) (interface{}, error) {
@ -32,6 +32,10 @@ func (q *ClosedOrderBatchQuery) Query(ctx context.Context, symbol string, startT
JumpIfEmpty: 30 * 24 * time.Hour, JumpIfEmpty: 30 * 24 * time.Hour,
} }
for _, opt := range opts {
opt(query)
}
c = make(chan types.Order, 100) c = make(chan types.Order, 100)
errC = query.Query(ctx, c, startTime, endTime) errC = query.Query(ctx, c, startTime, endTime)
return c, errC return c, errC