Documentation
¶
Overview ¶
Command middleware shows how to wrap a Handler[T] with taskQ middleware: structured logging, a hand-written recorder, and panic recovery — composed with taskq.Chain and run by the built-in taskq.Pool.
Middleware order matters. taskq.Chain(base, A, B, C) runs as A(B(C(base))): the first listed is outermost — it sees the task first and the returned error last. Per the package docs, RecoveryMiddleware goes LAST (innermost, directly wrapping the handler) so the *PanicError it produces is visible to the middleware listed before it — here, the recorder and the logger.
Run it with:
go run ./examples/membroker/middleware
Click to show internal directories.
Click to hide internal directories.