Documentation
¶
Overview ¶
Package middleware provides composable middleware for the Weave pipeline. Middleware wraps pipeline step execution, enabling cross-cutting concerns like caching, tracing, and tenant isolation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides a simple in-memory cache middleware for pipeline steps. It caches step results keyed by the step name and a hash of the StepContext contents.
func (*Cache) Middleware ¶
func (c *Cache) Middleware(names ...string) Middleware
Middleware returns a Middleware that caches step outputs. Only steps whose names match one of the given names are cached. If no names are provided, all steps are cached.
type LogTracer ¶
LogTracer is a simple TracingHook that prints to a function.
type Middleware ¶
type Middleware func(next StepHandler) StepHandler
Middleware wraps step execution.
func Chain ¶
func Chain(mws ...Middleware) Middleware
Chain composes multiple middleware into a single Middleware. Middleware are applied left-to-right: the first middleware in the chain is the outermost wrapper.
func Tenant ¶
func Tenant() Middleware
Tenant returns a Middleware that extracts the tenant from the context and injects it into the pipeline step context under the standard tenant_id key.
func Tracing ¶
func Tracing(hook TracingHook) Middleware
Tracing returns a Middleware that calls the given hook before and after each pipeline step.
type StepHandler ¶
type StepHandler func(ctx context.Context, sc *pipeline.StepContext) error
StepHandler executes a pipeline step.
type TracingHook ¶
type TracingHook interface {
// BeforeStep is called before a pipeline step executes.
BeforeStep(ctx context.Context, stepName string)
// AfterStep is called after a pipeline step completes.
AfterStep(ctx context.Context, stepName string, err error)
}
TracingHook is called before and after each step for custom tracing.