mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2025-02-23 16:08:42 +01:00
* Previosuly the worker queue pool buffer size was 1 which applies a backpressure on the fast missing blocks producer * Define our queue size and why we chose this value
30 lines
563 B
Go
30 lines
563 B
Go
package pool
|
|
|
|
import (
|
|
"log/slog"
|
|
"runtime/debug"
|
|
|
|
"github.com/alitto/pond"
|
|
)
|
|
|
|
type PoolOpts struct {
|
|
Logg *slog.Logger
|
|
WorkerCount int
|
|
BlocksBuffer int
|
|
}
|
|
|
|
func NewPool(o PoolOpts) *pond.WorkerPool {
|
|
return pond.New(
|
|
o.WorkerCount,
|
|
o.BlocksBuffer,
|
|
pond.Strategy(pond.Balanced()),
|
|
pond.PanicHandler(panicHandler(o.Logg)),
|
|
)
|
|
}
|
|
|
|
func panicHandler(logg *slog.Logger) func(interface{}) {
|
|
return func(panic interface{}) {
|
|
logg.Error("block processor goroutine exited from a panic", "error", panic, "stack_trace", string(debug.Stack()))
|
|
}
|
|
}
|