mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-22 23:56:46 +01:00
Mohammed Sohail
2bbc05bb45
* This is a major refactor and includes general improvements around - context cancellation - build settings - jetstream pub sub - logging - docker builds - conf loading
29 lines
445 B
Go
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),
|
|
)
|
|
}
|