mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-29 18:16:47 +01:00
Mohammed Sohail
df88d9df16
* 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
25 lines
433 B
Go
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),
|
|
)
|
|
}
|