github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/xcontext/idempotent.go (about) 1 package xcontext 2 3 import "context" 4 5 type ctxIdempotentKey struct{} 6 7 func WithIdempotent(ctx context.Context, idempotent bool) context.Context { 8 return context.WithValue(ctx, 9 ctxIdempotentKey{}, 10 idempotent, 11 ) 12 } 13 14 func IsIdempotent(ctx context.Context) bool { 15 if idempotent, ok := ctx.Value(ctxIdempotentKey{}).(bool); ok { 16 return idempotent 17 } 18 19 return false 20 }