Documentation ¶
Index ¶
- Variables
- func ExecFunc(ctx context.Context, fn func()) error
- func ExecFuncWithThreeReturns[T1 any, T2 any](ctx context.Context, fn func() (T1, T2, error)) (T1, T2, error)
- func ExecFuncWithTwoReturns[T1 any](ctx context.Context, fn func() (T1, error)) (T1, error)
- func ValueOrDefault(value interface{}) context.Context
- func WithValues(ctx context.Context, keyValue ...ContextArg) (context.Context, error)
- type ContextArg
Constants ¶
This section is empty.
Variables ¶
var DefaultContext = context.TODO()
var ErrIncorrectNumberOfItems = errors.New("number of items is not even")
Functions ¶
func ExecFunc ¶ added in v0.0.62
ExecFunc implements context for a function which has no return values and executes that function. if context is cancelled before function returns it will return context error otherwise it will return nil
func ExecFuncWithThreeReturns ¶ added in v0.0.62
func ExecFuncWithThreeReturns[T1 any, T2 any](ctx context.Context, fn func() (T1, T2, error)) (T1, T2, error)
ExecFuncWithThreeReturns wraps a function which has three return values given that last one is error and executes that function in a goroutine there by implementing context if context is cancelled before function returns it will return context error otherwise it will return function's return values
func ExecFuncWithTwoReturns ¶ added in v0.0.62
ExecFuncWithTwoReturns wraps a function which has two return values given that last one is error and executes that function in a goroutine there by implementing context if context is cancelled before function returns it will return context error otherwise it will return function's return values
func ValueOrDefault ¶ added in v0.0.48
ValueOrDefault returns default context if given is nil (using interface to avoid static check reporting)
func WithValues ¶
WithValues combines multiple key-value into an existing context
Types ¶
type ContextArg ¶ added in v0.0.48
type ContextArg string