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

28
components/metrics/ctx.go Normal file
View File

@@ -0,0 +1,28 @@
package metrics
import "context"
type contextValue int
const (
publishObserved contextValue = iota
subscribeObserved
)
// setPublishObservedToCtx is used to achieve metrics idempotency in case of double applied middleware
func setPublishObservedToCtx(ctx context.Context) context.Context {
return context.WithValue(ctx, publishObserved, true)
}
func publishAlreadyObserved(ctx context.Context) bool {
return ctx.Value(publishObserved) != nil
}
// setSubscribeObservedToCtx is used to achieve metrics idempotency in case of double applied middleware
func setSubscribeObservedToCtx(ctx context.Context) context.Context {
return context.WithValue(ctx, subscribeObserved, true)
}
func subscribeAlreadyObserved(ctx context.Context) bool {
return ctx.Value(subscribeObserved) != nil
}