mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-16 18:05:20 +02:00
release: v1.0.0
This commit is contained in:
28
internal/pool/pool.go
Normal file
28
internal/pool/pool.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package pool
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/alitto/pond"
|
||||
)
|
||||
|
||||
type PoolOpts struct {
|
||||
Logg *slog.Logger
|
||||
WorkerCount int
|
||||
}
|
||||
|
||||
func NewPool(o PoolOpts) *pond.WorkerPool {
|
||||
return pond.New(
|
||||
o.WorkerCount,
|
||||
1,
|
||||
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()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user