Skip to content

Commit

Permalink
Remove context-related configuration options from WorkerGroup
Browse files Browse the repository at this point in the history
this is not needed anymore, as Go func accepts external context
  • Loading branch information
umputun committed Feb 9, 2025
1 parent 70f2426 commit 03dedb7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ p := pool.New[string](2, worker).
WithBatchSize(10). // process items in batches
WithWorkerChanSize(5). // set worker channel buffer size
WithChunkFn(chunkFn). // control work distribution
WithContext(ctx). // set custom context
WithContinueOnError(). // don't stop on errors
WithCompleteFn(completeFn) // called when worker finishes
```
Expand All @@ -376,7 +375,6 @@ Available options:
- `WithBatchSize(size int)` - enables batch processing, accumulating items before sending to workers
- `WithWorkerChanSize(size int)` - sets buffer size for worker channels
- `WithChunkFn(fn func(T) string)` - controls work distribution by key
- `WithContext(ctx context.Context)` - sets custom context for cancellation
- `WithContinueOnError()` - continues processing on errors
- `WithCompleteFn(fn func(ctx, id, worker))` - called on worker completion

Expand Down
8 changes: 0 additions & 8 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func New[T any](size int, worker Worker[T]) *WorkerGroup[T] {
worker: worker,
batchSize: 1,
workerChanSize: 1,
ctx: context.Background(),
}
res.err.ch = make(chan struct{})

Expand Down Expand Up @@ -156,13 +155,6 @@ func (p *WorkerGroup[T]) WithChunkFn(fn func(T) string) *WorkerGroup[T] {
return p
}

// WithContext sets the context for the pool. This is used to control the lifecycle of the pool.
// Default: context.Background()
func (p *WorkerGroup[T]) WithContext(ctx context.Context) *WorkerGroup[T] {
p.ctx = ctx
return p
}

// WithContinueOnError sets whether the pool should continue on error.
// Default: false
func (p *WorkerGroup[T]) WithContinueOnError() *WorkerGroup[T] {
Expand Down

0 comments on commit 03dedb7

Please sign in to comment.