Skip to content

Commit

Permalink
refactor: Modify batch processing preparation for shipping method
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jun 17, 2024
1 parent f66c956 commit bad9282
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/processor/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,18 @@ func (bvp *BatchItemProcessor[T]) Write(ctx context.Context, s []*T) error {
}

prepared := []traceableItem[T]{}

for _, i := range s[start:end] {
prepared = append(prepared, traceableItem[T]{
item: i,
errCh: make(chan error, 1),
completedCh: make(chan struct{}, 1),
})
item := traceableItem[T]{
item: i,
}

if bvp.o.ShippingMethod == ShippingMethodSync {
item.errCh = make(chan error, 1)
item.completedCh = make(chan struct{}, 1)
}

prepared = append(prepared, item)
}

for _, i := range prepared {
Expand Down

0 comments on commit bad9282

Please sign in to comment.