Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Component = &component.Component{ Name: "runner.recover", Dependencies: component.Components{ runner.Component, }, Init: component.StepFunc(func(container container.Container) error { return container.Provide(NewRecover) }), PreExecute: component.StepFunc(func(container container.Container) error { return container.Invoke(func(r runner.Runner, middleware *Recover) { r.Use(middleware) }) }), }
Component is a ready-to-use Compogo component that automatically adds panic recovery middleware to the application's runner.
It depends on runner.Component and registers itself during the PreRun phase.
Usage:
compogo.WithComponents(
runner.Component,
recover.Component, // ← protects all tasks from panics
)
Functions ¶
This section is empty.
Types ¶
type Recover ¶
type Recover struct {
// contains filtered or unexported fields
}
Recover is a middleware that catches panics in task execution, logs them with stack traces, and prevents them from crashing the application.
func NewRecover ¶
NewRecover creates a new Recover middleware instance. The provided logger is used to log panic details including stack traces.
func (*Recover) Middleware ¶
Middleware wraps a task's process function with panic recovery. If the wrapped process panics, it is recovered, logged, and the panic is not propagated further. The task will continue running (the panic only affects the current execution, not the task itself).