Documentation ¶
Index ¶
- func AppendToIncomingContext(ctx context.Context, kv ...string) context.Context
- func GetAuthInfoFromContext(ctx context.Context) (string, string, error)
- func GetCurUserFromContext(ctx context.Context) (string, error)
- func TenantID(ctx context.Context) string
- func WithDeadlineCause(parent context.Context, deadline time.Time, err error) (context.Context, context.CancelFunc)
- func WithTenantID(ctx context.Context, tenantID string) context.Context
- func WithTimeoutCause(parent context.Context, timeout time.Duration, err error) (context.Context, context.CancelFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToIncomingContext ¶
func GetAuthInfoFromContext ¶
func TenantID ¶
TenantID tries to retrieve tenantID from the given context. If it doesn't exist, an empty string is returned.
func WithDeadlineCause ¶
func WithDeadlineCause(parent context.Context, deadline time.Time, err error) (context.Context, context.CancelFunc)
TODO: use context.WithDeadlineCause instead in go 1.21.0, then deprecated this function !!! We cannot keep same implementation with context.WithDeadlineCause. if cancel happens, context.WithDeadlineCause will return context.Err() == context.DeadlineExceeded and context.Cause(ctx) == err. if cancel happens, WithDeadlineCause will return context.Err() == context.Canceled and context.Cause(ctx) == err.
func WithTenantID ¶
WithTenantID creates a new context that has tenantID injected.
func WithTimeoutCause ¶
func WithTimeoutCause(parent context.Context, timeout time.Duration, err error) (context.Context, context.CancelFunc)
TODO: use context.WithTimeoutCause instead in go 1.21.0, then deprecated this function !!! We cannot keep same implementation with context.WithDeadlineCause. if cancel happens, context.WithTimeoutCause will return context.Err() == context.Timeout and context.Cause(ctx) == err. if cancel happens, WithTimeoutCause will return context.Err() == context.Canceled and context.Cause(ctx) == err.
Types ¶
This section is empty.