MCPcopy Create free account
hub / github.com/riverqueue/river / NewMiddlewareCustomContext

Function NewMiddlewareCustomContext

riverlog/river_log.go:144–149  ·  view source on GitHub ↗

NewMiddlewareCustomContext initializes a new Middleware with the given arbitrary context initialization function and configuration. newContext is a function which is invoked on every Work execution to generate a new context for the worker. It's generally used to initialize a logger with the given w

(newCustomContext func(ctx context.Context, w io.Writer) context.Context, config *MiddlewareConfig)

Source from the content-addressed store, hash-verified

142// return context.WithValue(ctx, ArbitraryContextKey{}, logger)
143// }, nil),
144func NewMiddlewareCustomContext(newCustomContext func(ctx context.Context, w io.Writer) context.Context, config *MiddlewareConfig) *Middleware {
145 return &Middleware{
146 config: defaultConfig(config),
147 newCustomContext: newCustomContext,
148 }
149}
150
151func defaultConfig(config *MiddlewareConfig) *MiddlewareConfig {
152 if config == nil {

Callers 1

Calls 1

defaultConfigFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…