type DoWorkPieceFunc … type options … type Options … // WithChunkSize allows to set chunks of work items to the workers, rather than // processing one by one. // It is recommended to use this option if the number of pieces significantly // higher than the number of workers and the work done for each item is small. func WithChunkSize(c int) func(*options) { … } // ParallelizeUntil is a framework that allows for parallelizing N // independent pieces of work until done or the context is canceled. func ParallelizeUntil(ctx context.Context, workers, pieces int, doWorkPiece DoWorkPieceFunc, opts ...Options) { … } func ceilDiv(a, b int) int { … }