mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-06 01:36:45 +01:00
Mohammed Sohail
ef9f2b2b7f
* fully drain worker queue before reading gap from db * dedicated go routine for head syncer * emit blok, tx index and hash to jetstream
25 lines
405 B
Go
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),
|
|
)
|
|
}
|