cic-chain-events/internal/pool/pool.go
Mohammed Sohail ef9f2b2b7f
hotfix: drain janitor queue, worker pool, js
* fully drain worker queue before reading gap from db
* dedicated go routine for head syncer
* emit blok, tx index and hash to jetstream
2023-01-18 22:40:14 +03:00

25 lines
405 B
Go

package pool
import (
"context"
"time"
"github.com/alitto/pond"
)
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(time.Second*1),
pond.Context(ctx),
)
}