Skip to content

Releases: go-coldbrew/workers

v0.2.1

27 Apr 05:11
790585f

Choose a tag to compare

Remove ensureSampled hack from Tracing middleware — worker ticks now create natural OTel root spans with sampling governed by the global TracerProvider's sampler.

v0.2.0

26 Apr 14:03
3626332

Choose a tag to compare

What's Changed

Zombie child auto-cleanup

Stopped children are automatically pruned from GetChildren/GetChild/GetChildCount via a done channel closed on permanent stop. No manual cleanup needed.

ErrSkipTick

New sentinel for periodic handlers to skip a tick without triggering restart — useful for transient failures (DB timeouts, network blips). The timer continues and the next tick fires normally.

Always-sampled worker traces

middleware.Tracing() now ensures worker root spans are always sampled, fixing silent span drops with ParentBased(TraceIDRatioBased(...)) samplers. OTEL trace ID is injected into the log context as trace for correlation.

New APIs

  • WorkerInfo.GetHandler() — access the current worker's CycleHandler for type assertion (handler-as-metadata pattern)
  • WorkerInfo.GetChildCount() — efficient child count without allocating a sorted slice
  • Worker.GetInterval(), Worker.GetRestartOnFail(), Worker.GetJitterPercent(), Worker.GetInitialDelay() — config introspection for reconciler patterns
  • middleware.WithSkipOnNotAcquired() — convenience LockOption for log-and-skip when distributed lock is held

Documentation

  • Error semantics decision table for periodic handlers
  • Run-level vs worker-level interceptor guidance
  • Handler-as-metadata reconciler example (Example_reconcilerWithChangeDetection)
  • WithOnNotAcquired footgun warning
  • Locker interface compatibility note

v0.1.0

24 Apr 14:23
d124a58

Choose a tag to compare

Workers v0.1.0 — Jitter, Middleware, and API Redesign

Breaking changes (from v0.0.x)

  • NewWorker(name, fn)NewWorker(name).HandlerFunc(fn)
  • WorkerContext*WorkerInfo with GetName(), GetAttempt() getters
  • ctx.Add/Remove/Childreninfo.Add/Remove/GetChildren
  • Add is now a no-op if name exists (returns bool) — use Remove + Add to replace
  • Restart enabled by default — WithRestart(false) to disable
  • ChannelWorker/BatchChannelWorker callback signatures updated

New features

  • Composable middleware — gRPC-style interceptor chain with Interceptors() / AddInterceptors() / WithInterceptors()
  • Built-in middleware (middleware/ sub-package): Recover, Tracing, Duration, Timeout, Slog, LogContext, DistributedLock, DefaultInterceptors
  • JitterWithJitter(percent), WithDefaultJitter(percent), WithInitialDelay(d) to prevent thundering herd
  • ErrDoNotRestart — explicit permanent completion signal
  • CycleHandler interface with Close() — resource cleanup on permanent stop
  • Worker.GetChild() — inspect running children (returns value copy)
  • WithTestChildren(ctx) — testable WorkerInfo without running full supervisor
  • Slim Serve() — tracing/logging moved to middleware; core drops go-coldbrew/log and go-coldbrew/tracing imports
  • WithBackoffJitter accepts func(time.Duration) time.Duration — no suture dependency leak

v0.0.4

05 Apr 15:46
0c62e84

Choose a tag to compare

feat: export BaseMetrics for forward-compatible custom Metrics implementations, use value type to avoid allocation

v0.0.3

05 Apr 15:20
efe3938

Choose a tag to compare

feat: Metrics interface with Prometheus implementation, log context injection, safe NewPrometheusMetrics caching

v0.0.2

05 Apr 11:26

Choose a tag to compare

chore: add LICENSE (Apache 2.0), .gitignore, badges, enhanced package docs, AGENTS.md

v0.0.1

05 Apr 07:42

Choose a tag to compare

Initial release — worker lifecycle library built on suture with builder pattern, WorkerContext, dynamic child workers, helpers (EveryInterval, ChannelWorker, BatchChannelWorker), tracing, and logging