cic-chain-events/internal/pool/pool.go
Mohammed Sohail 2bbc05bb45
major refactor: sig ch, remove conf settings, jetstream pub, ci
* This is a major refactor and includes general improvements around

- context cancellation
- build settings
- jetstream pub sub
- logging
- docker builds
- conf loading
2023-03-08 14:30:40 +00:00

29 lines
445 B
Go

package pool
import (
"context"
"time"
"github.com/alitto/pond"
)
const (
idleTimeout = 1 * time.Second
)
type Opts struct {
Concurrency int
QueueSize int
}
// NewPool creates a fixed size (and buffered) go routine worker pool.
func NewPool(ctx context.Context, o Opts) *pond.WorkerPool {
return pond.New(
o.Concurrency,
o.QueueSize,
pond.MinWorkers(o.Concurrency),
pond.IdleTimeout(idleTimeout),
pond.Context(ctx),
)
}