cic-chain-events/internal/pool/pool.go
Mohammed Sohail df88d9df16
refactor: perf, update libraries ci, and add docs
* update config to better defaults
* add docs, inline and md
* add context support throughout
* replace json with goccy/go-json for better decoding of large JSON
* update graphql fetcher: replace ioutil with io
* test runner script (until CI is ready)
* update CI build config
2023-01-11 08:13:59 +00:00

25 lines
433 B
Go

package pool
import (
"context"
"time"
"github.com/alitto/pond"
)
type Opts struct {
ConcurrencyFactor int
PoolQueueSize 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.ConcurrencyFactor,
o.PoolQueueSize,
pond.MinWorkers(o.ConcurrencyFactor),
pond.IdleTimeout(time.Second*1),
pond.Context(ctx),
)
}