middleware

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsumeHandler

type ConsumeHandler func(ctx context.Context, d transport.Delivery, env event.Envelope) error

ConsumeHandler is the inner function a ConsumeMiddleware wraps. The Delivery is exposed so middleware can inspect Attempt counts and Ack/Nack the message directly (e.g. inbox dedupe).

func ChainConsume

ChainConsume composes consume middlewares filtered by transport capabilities. The first applicable middleware becomes the outermost wrapper. Nil entries are skipped (see ChainPublish).

type ConsumeMiddleware

type ConsumeMiddleware interface {
	// Name identifies the middleware for ordering and diagnostics.
	Name() string
	// Applies reports whether the middleware should attach to a
	// transport with the given capabilities. For example, Inbox
	// returns false on non-AtLeastOnce transports to avoid pointless
	// database writes.
	Applies(caps transport.Capabilities) bool
	// WrapConsume returns a new handler that wraps next.
	WrapConsume(next ConsumeHandler) ConsumeHandler
}

ConsumeMiddleware augments the consume pipeline. Implementations run before the user-registered handler and may transform context, log, dedupe, capture metrics, recover panics, etc.

type PublishHandler

type PublishHandler func(ctx context.Context, env *event.Envelope) error

PublishHandler is the inner function a PublishMiddleware wraps.

func ChainPublish

func ChainPublish(mws []PublishMiddleware, base PublishHandler) PublishHandler

ChainPublish composes middlewares in order: the first element in mws becomes the outermost wrapper. Nil entries are skipped so opt-out constructors (returning nil under disabled feature flags) compose safely with fx groups.

type PublishMiddleware

type PublishMiddleware interface {
	// Name identifies the middleware for ordering and diagnostics.
	Name() string
	// WrapPublish returns a new handler that wraps next with the
	// middleware's behavior.
	WrapPublish(next PublishHandler) PublishHandler
}

PublishMiddleware augments the publish pipeline. Implementations can mutate the Envelope (e.g. inject tracing headers) before invoking next, or short-circuit by returning without calling next.

Jump to

Keyboard shortcuts

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