Installation and Quick Start
Installation
Section titled “Installation”go get github.com/iyashjayesh/go-adaptive-poolThe core has no dependency on Prometheus or OpenTelemetry. The metrics adapters are separate modules; add the one you use:
go get github.com/iyashjayesh/go-adaptive-pool/promrecorder # Prometheusgo get github.com/iyashjayesh/go-adaptive-pool/otelrecorder # OpenTelemetryQuick Start
Section titled “Quick Start”Here is a simple example of how to create a pool and submit a job.
package main
import ( "context" "log" "time"
"github.com/iyashjayesh/go-adaptive-pool")
func main() { // creating pool pool, err := adaptivepool.New( adaptivepool.WithMinWorkers(4), adaptivepool.WithMaxWorkers(32), adaptivepool.WithQueueSize(1000), ) if err != nil { log.Fatal(err) } defer pool.Shutdown(context.Background())
// Submit job job := func(ctx context.Context) error { // Your work here time.Sleep(100 * time.Millisecond) return nil }
if err := pool.Submit(context.Background(), job); err != nil { log.Printf("Failed to Submit: %v", err) }}Next steps
Section titled “Next steps”- Configuration: every option and its default
- Auto-Configuration: size the pool from a workload profile
- Core Concepts: backpressure, metrics and shutdown
- Retries: retry failed jobs with backoff
- Observability: task identity, metrics exporters, logs and the
OnTaskDonehook