github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/xcontext/local_dc.go (about) 1 package xcontext 2 3 import ( 4 "context" 5 "fmt" 6 ) 7 8 type localDcKey struct{} 9 10 func WithLocalDC(ctx context.Context, dc string) context.Context { 11 return context.WithValue(ctx, localDcKey{}, dc) 12 } 13 14 func ExtractLocalDC(ctx context.Context) string { 15 if val := ctx.Value(localDcKey{}); val != nil { 16 s, ok := val.(string) 17 if !ok { 18 panic(fmt.Sprintf("unsupported type conversion from %T to string", s)) 19 } 20 21 return s 22 } 23 24 return "" 25 }