github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/balancer/ctx.go (about) 1 package balancer 2 3 import "context" 4 5 type ( 6 ctxEndpointKey struct{} 7 ) 8 9 type Endpoint interface { 10 NodeID() uint32 11 } 12 13 func WithEndpoint(ctx context.Context, endpoint Endpoint) context.Context { 14 return context.WithValue(ctx, ctxEndpointKey{}, endpoint) 15 } 16 17 func ContextEndpoint(ctx context.Context) (e Endpoint, ok bool) { 18 if e, ok = ctx.Value(ctxEndpointKey{}).(Endpoint); ok { 19 return e, true 20 } 21 22 return nil, false 23 }