Help us shape the future of Go! Take the 2026 Go Developer Survey

decorators

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package decorators provides logging, metrics, tracing, and recovery wrappers for interfaces.AnyJob. They compose via Wrap(job).WithLogger(..).WithMetrics(..). WithTracing(..).WithRecovery().Build(), and are backward-compatible: a chain with no decorators returns the inner job unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder wraps an AnyJob with optional logging, metrics, tracing, and recovery decorators.

func Wrap

func Wrap(job interfaces.AnyJob) *Builder

Wrap starts a decoration chain for job.

func (*Builder) Build

func (b *Builder) Build() interfaces.AnyJob

Build returns the decorated job. Decorators are layered innermost→outermost as recovery → logging → metrics → tracing, so a panic is converted first and the outer layers observe it as a normal failure. A chain with no decorators returns the inner job unchanged.

func (*Builder) WithLogger

func (b *Builder) WithLogger(logger interfaces.Logger) *Builder

WithLogger adds structured logging around the job.

func (*Builder) WithMetrics

func (b *Builder) WithMetrics(metrics interfaces.Metrics) *Builder

WithMetrics adds run-count + duration metrics around the job.

func (*Builder) WithRecovery

func (b *Builder) WithRecovery() *Builder

WithRecovery adds panic→error recovery (innermost, so logging/metrics/tracing still observe the converted failure).

func (*Builder) WithTracing

func (b *Builder) WithTracing(tracer interfaces.Tracer) *Builder

WithTracing adds a per-run span around the job.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL