github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/endpoint/context.go (about) 1 package endpoint 2 3 import "context" 4 5 type ( 6 ctxEndpointKey struct{} 7 ) 8 9 func WithNodeID(ctx context.Context, nodeID uint32) context.Context { 10 return context.WithValue(ctx, ctxEndpointKey{}, nodeID) 11 } 12 13 func ContextNodeID(ctx context.Context) (nodeID uint32, ok bool) { 14 if nodeID, ok = ctx.Value(ctxEndpointKey{}).(uint32); ok { 15 return nodeID, true 16 } 17 18 return 0, false 19 }