2023-09-15 00:07:07 +08:00
|
|
|
package interrupt
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
type contextKeyIsExternalConnection struct{}
|
|
|
|
|
|
|
|
|
|
func ContextWithIsExternalConnection(ctx context.Context) context.Context {
|
|
|
|
|
return context.WithValue(ctx, contextKeyIsExternalConnection{}, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsExternalConnectionFromContext(ctx context.Context) bool {
|
|
|
|
|
return ctx.Value(contextKeyIsExternalConnection{}) != nil
|
|
|
|
|
}
|
2026-04-29 22:11:30 +03:00
|
|
|
|
|
|
|
|
type contextKeyIsProviderConnection struct{}
|
|
|
|
|
|
|
|
|
|
func ContextWithIsProviderConnection(ctx context.Context) context.Context {
|
|
|
|
|
return context.WithValue(ctx, contextKeyIsProviderConnection{}, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsProviderConnectionFromContext(ctx context.Context) bool {
|
|
|
|
|
return ctx.Value(contextKeyIsProviderConnection{}) != nil
|
|
|
|
|
}
|