Documentation
¶
Overview ¶
Package adapters provides chi-style middleware around the runnable RunFunc signature. Each constructor returns a runnable.Adapter; compose them via runnable.WithAdapters (first listed = outermost):
r := runnable.New(reconcile, runnable.WithAdapters(
adapters.Draining(10*time.Second),
adapters.Ticker(time.Second),
))
Index ¶
Constants ¶
const ResetNever time.Duration = 0
ResetNever (as resetAfter) disables retry-budget reset.
Variables ¶
var ErrDrainTimedOut = errors.New("adapters: drain timed out")
ErrDrainTimedOut is returned by Draining when work did not exit within the drain timeout and was force-cancelled.
Functions ¶
func Draining ¶
Draining returns an Adapter that delays cancellation: when outerCtx is cancelled, next has up to timeout to return via Stopping(workCtx) before workCtx is force-cancelled and ErrDrainTimedOut is returned. Panics in next are recovered into an error (they would otherwise crash the process, since next runs on its own goroutine).
func Recovering ¶
Recovering returns an Adapter that converts panics from next into errors and publishes a runnable.PanicRecoveredEvent to the Publisher on ctx, if any. Place inside Draining when both are used, so the Publisher sees the panic before Draining's safety-net recovery formats it.
func Retry ¶
Retry returns an Adapter that re-invokes next up to maxRetries times on non-context errors. If resetAfter > 0 and at least that long has passed since the previous attempt, the budget resets. Each failed attempt publishes a runnable.RetryEvent (Attempt is 1-indexed). Retry does not observe Stopping — wrap it inside Draining if you need both.
Types ¶
This section is empty.