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)
| 142 | // return context.WithValue(ctx, ArbitraryContextKey{}, logger) |
| 143 | // }, nil), |
| 144 | func 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 | |
| 151 | func defaultConfig(config *MiddlewareConfig) *MiddlewareConfig { |
| 152 | if config == nil { |
searching dependent graphs…