Skip to content

Commit

Permalink
Merge pull request #66 from Icinga/BatchSliceOfStrings-0
Browse files Browse the repository at this point in the history
BatchSliceOfStrings(): panic if count <= 0
  • Loading branch information
yhabteab authored Sep 2, 2024
2 parents 15703e6 + 080e15a commit bd2bf65
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func Timed(start time.Time, callback func(elapsed time.Duration)) {
}

// BatchSliceOfStrings groups the given keys into chunks of size count and streams them into a returned channel.
// Panics if count is less than or equal to zero.
func BatchSliceOfStrings(ctx context.Context, keys []string, count int) <-chan []string {
if count <= 0 {
panic("chunk size must be greater than zero")
}

batches := make(chan []string)

go func() {
Expand Down

0 comments on commit bd2bf65

Please sign in to comment.