Pass context into pubsub to CQRS handler
- Warning: should using in single pod command. (cqrs)
- Only work in go channel pub/sub mode.
go get -u "github.com/hpcslag/watermill-otel-tracable-gochannel"
Setup
import otelTraceChannel "github.com/hpcslag/watermill-otel-tracable-gochannel/gochannel"
// Important to use JSON Marshaler
cqrsMarshaler := cqrs.JSONMarshaler{}
router, err := message.NewRouter(message.RouterConfig{}, logger)
if err != nil {
panic(err)
}
// ...
commandsChannel := otelTraceChannel.NewGoChannel(
otelTraceChannel.Config{},
watermill.NewStdLogger(true, true),
)
// ...
Original code please refer to watermill repository: https://github.com/ThreeDotsLabs/watermill/blob/master/pubsub/gochannel/pubsub.go