Documentation
¶
Overview ¶
Package async provides supported contrib worker runner contracts for durable async jobs.
The package includes a bounded runner, low-cardinality metric hooks, safe failure-message helpers, and a job-kind handler mux for sharing one durable queue across multiple worker concerns without routing on unbounded payload data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidJobKind reports a missing or unsafe async job kind. ErrInvalidJobKind = errors.New("invalid async job kind") // ErrHandlerNotFound reports a missing async handler registration. ErrHandlerNotFound = errors.New("async handler not found") )
Functions ¶
func SafeFailureMessage ¶
SafeFailureMessage bounds failure messages before durable storage.
Types ¶
type Config ¶
type Config struct {
Store Store
Handler Handler
Logger ports.Logger
Metrics MetricsRecorder
BatchSize int
Concurrency int
PollInterval time.Duration
}
Config configures a Runner.
type HandlerFunc ¶
HandlerFunc adapts a function to Handler.
type HandlerMux ¶
type HandlerMux struct {
// contains filtered or unexported fields
}
HandlerMux dispatches jobs to handlers by sanitized low-cardinality kind.
func NewHandlerMux ¶
func NewHandlerMux(routes ...HandlerRoute) (*HandlerMux, error)
NewHandlerMux constructs a mux and registers the supplied routes.
func (*HandlerMux) Handle ¶
func (m *HandlerMux) Handle(ctx context.Context, job Job) error
Handle dispatches job to the registered handler for job.Kind.
func (*HandlerMux) Kinds ¶
func (m *HandlerMux) Kinds() []string
Kinds returns registered job kinds in sorted order.
type HandlerRoute ¶
HandlerRoute registers a handler for a low-cardinality job kind.
type MetricsRecorder ¶
MetricsRecorder records worker outcomes.
type MetricsRecorderFunc ¶
MetricsRecorderFunc adapts a function to MetricsRecorder.
func (MetricsRecorderFunc) ObserveAsyncJob ¶
func (f MetricsRecorderFunc) ObserveAsyncJob(ctx context.Context, event Event)
ObserveAsyncJob records an async job event.