contextutil

package
v0.0.2-0...-993051b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToIncomingContext

func AppendToIncomingContext(ctx context.Context, kv ...string) context.Context

func GetAuthInfoFromContext

func GetAuthInfoFromContext(ctx context.Context) (string, string, error)

func GetCurUserFromContext

func GetCurUserFromContext(ctx context.Context) (string, error)

func TenantID

func TenantID(ctx context.Context) string

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

func WithTenantID(ctx context.Context, tenantID string) context.Context

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL