Documentation
¶
Overview ¶
Package context contains generated code by adptool.
Package context provides the context functions ¶
Package context provides the context functions
Index ¶
- Variables
- func AfterFunc(ctx context.Context, f func()) (stop func() bool)
- func Background() context.Context
- func Cause(c context.Context) error
- func FromCreatedBy(ctx Context) string
- func FromDB(ctx Context) (any, bool)
- func FromID(ctx Context) string
- func FromMapContext(parent Context) map[any]any
- func FromRowLock(ctx Context) bool
- func FromSpan(ctx Context) string
- func FromStack(ctx Context) string
- func FromTag(ctx Context) string
- func FromToken(ctx Context) string
- func FromTrace(ctx Context) string
- func FromTrans(ctx Context) (any, bool)
- func FromUserCache(ctx Context) (any, bool)
- func IsNameSkipped(ctx Context, name string) bool
- func IsSkipped(ctx Context) bool
- func TODO() context.Context
- func Value(ctx Context, key any) any
- func WithCancel(parent context.Context) (ctx context.Context, cancel context.CancelFunc)
- func WithCancelCause(parent context.Context) (ctx context.Context, cancel context.CancelCauseFunc)
- func WithDeadline(parent context.Context, d time.Time) (context.Context, context.CancelFunc)
- func WithDeadlineCause(parent context.Context, d time.Time, cause error) (context.Context, context.CancelFunc)
- func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- func WithTimeoutCause(parent context.Context, timeout time.Duration, cause error) (context.Context, context.CancelFunc)
- func WithValue(parent context.Context, key, val any) context.Context
- func WithoutCancel(parent context.Context) context.Context
- type CancelCauseFunc
- type CancelFunc
- type Context
- func NewCreatedBy(ctx Context, by string) Context
- func NewDB(ctx Context, db any) Context
- func NewID(ctx Context, id string) Context
- func NewNamedSkip(ctx Context, name ...string) Context
- func NewRowLock(ctx Context) Context
- func NewSkip(ctx Context) Context
- func NewSpan(ctx Context, span string) Context
- func NewStack(ctx Context, stack string) Context
- func NewTag(ctx Context, tag string) Context
- func NewToken(ctx Context, token string) Context
- func NewTrace(ctx Context, trace string) Context
- func NewTrans(ctx Context, tx any) Context
- func NewUserCache(ctx Context, userCache any) Context
- func WithContext(ctxs ...Context) Context
- func WithMapValue(parent Context, key, val any) Context
Constants ¶
This section is empty.
Variables ¶
var ( Canceled = context.Canceled DeadlineExceeded = context.DeadlineExceeded )
Functions ¶
func Background ¶
func FromCreatedBy ¶
FromCreatedBy retrieves the creator information from the given context.
It takes a Context as a parameter and returns a string.
func FromDB ¶
FromDB retrieves a db client from the context.
It takes a Context as a parameter and returns a db client.
func FromID ¶
FromID returns the user ID from the context.
It takes a Context as a parameter and returns a string.
func FromMapContext ¶
FromMapContext retrieves all values from the context.
func FromRowLock ¶
FromRowLock checks if the row is locked in the given context.
It takes a Context as a parameter and returns a boolean.
func FromSpan ¶
FromSpan returns the span id from the context.
It takes a Context as a parameter and returns a string.
func FromStack ¶
FromStack retrieves the stack from the context.
It takes a Context as a parameter and returns a string.
func FromTag ¶
FromTag retrieves the tag from the context.
It takes a Context as a parameter and returns a string.
func FromToken ¶
FromToken returns the user token from the context.
It takes a Context as a parameter and returns a string.
func FromTrace ¶
FromTrace returns the trace id from the context.
It takes a Context as a parameter and returns a string.
func FromUserCache ¶
FromUserCache returns the userCache from the context.
It takes a Context as a parameter and returns a userCache value.
func IsNameSkipped ¶ added in v0.2.3
IsNameSkipped checks if the context is skipped by name. It takes a Context and a name string as parameters and returns a boolean. The skip value is used to skip the middleware.
Example usage:
if context.IsNameSkipped(ctx, "name") {
return
}
func IsSkipped ¶ added in v0.2.2
IsSkipped checks if the context is skipped. It takes a Context as a parameter and returns a boolean. The skip value is used to skip the middleware.
Example usage:
if context.IsSkipped(ctx) {
return
}
func WithCancel ¶
func WithCancelCause ¶
func WithDeadline ¶
func WithDeadlineCause ¶
func WithTimeout ¶
func WithTimeoutCause ¶
Types ¶
type CancelCauseFunc ¶
type CancelCauseFunc = context.CancelCauseFunc
type CancelFunc ¶
type CancelFunc = context.CancelFunc
type Context ¶
func NewCreatedBy ¶
NewCreatedBy creates a new context with the provided 'by' value
It takes a Context and a 'by' string as parameters and returns a context.
func NewDB ¶
NewDB creates a new context with the provided db client value.
It takes a context and a db client as parameters and returns a context.
func NewID ¶
NewID returns a new context with the provided userID value.
It takes a context and a userID string as parameters and returns a context.
func NewNamedSkip ¶ added in v0.2.3
NewNamedSkip creates a new context with the skip value and name. It takes a context and a name string as parameters and returns a context. The skip value is used to skip the middleware.
Example usage:
ctx := context.NewNamedSkip(ctx, "name")
func NewRowLock ¶
NewRowLock creates a new context with a row lock value.
func NewSkip ¶ added in v0.2.2
NewSkip creates a new context with the skip value. It takes a context as a parameter and returns a context. The skip value is used to skip the middleware.
Example usage:
ctx := context.NewSkip(ctx)
func NewSpan ¶
NewSpan creates a new context with the provided span value.
It takes a context and a span string as parameters and returns a context.
func NewStack ¶
NewStack creates a new context with the provided stack value.
It takes a Context and a stack string as parameters and returns a context.
func NewTag ¶
NewTag creates a new context with the provided tag value.
It takes a Context and a tag string as parameters and returns a context.
func NewToken ¶
NewToken returns a new context with the provided userToken value.
It takes a context and a userToken string as parameters and returns a context.
func NewTrace ¶
NewTrace returns a new context with the provided trace value.
It takes a context and a trace string as parameters and returns a context.
func NewUserCache ¶
NewUserCache returns a new context with the provided userCache value.
It takes a Context and a userCache value as parameters and returns a context.
func WithContext ¶
WithContext returns a new context with the provided context.Context value. It takes a variadic parameter of type Context and returns a Context. If no contexts are provided, it returns a background context. Otherwise, it returns the first context in the variadic parameter.
Example usage:
ctx := context.WithContext(ctx1, ctx2, ctx3)
or
ctx := context.WithContext()
func WithMapValue ¶
WithMapValue creates a new context with the provided key-value pair. If the context saved over than 500 keys, use WithMapValue instead.