Skip to content

Commit

Permalink
wip: fix batch
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed May 30, 2024
1 parent 81d4d84 commit 738ddd9
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions pkg/utils/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,6 @@ func Batch[T any](ctx context.Context, ch <-chan T, batchSize int, fn func([]T))
fn(batch)
batch = make([]T, 0, batchSize) // reset
}
default:
if len(batch) > 0 { // partial
fmt.Println("<< 5")
fn(batch)
batch = make([]T, 0, batchSize) // reset
} else { // empty
// wait for more
select {
case <-ctx.Done():
return
case v, ok := <-ch:
if !ok {
return
}

batch = append(batch, v)
}
}
}
}
}

0 comments on commit 738ddd9

Please sign in to comment.