snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

27
components/cqrs/ctx.go Normal file
View File

@@ -0,0 +1,27 @@
package cqrs
import (
"context"
"github.com/ThreeDotsLabs/watermill/message"
)
type ctxKey string
const (
originalMessage ctxKey = "original_message"
)
// OriginalMessageFromCtx returns the original message that was received by the event/command handler.
func OriginalMessageFromCtx(ctx context.Context) *message.Message {
val, ok := ctx.Value(originalMessage).(*message.Message)
if !ok {
return nil
}
return val
}
// CtxWithOriginalMessage returns a new context with the original message attached.
func CtxWithOriginalMessage(ctx context.Context, msg *message.Message) context.Context {
return context.WithValue(ctx, originalMessage, msg)
}