Documentation
¶
Index ¶
- Variables
- func GetOverrideTimeout(ctx context.Context) (time.Duration, error)
- func GetProperTimeout(ctx context.Context, defaultDuration string) (timeout time.Duration, defaultUsed bool, err error)
- func GetVerbose(ctx context.Context) (bool, error)
- func WithOverrideTimeout(ctx context.Context, timeout time.Duration) context.Context
- func WithVerbose(ctx context.Context) context.Context
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorContextKeyFailedTypeCheck is returned when a value retrieved from a context fails a type-check ErrContextKeyFailedTypeCheck error = errors.New("returned value failed type-check") // ErrorContextKeyNotStored is returned when a requested key is not stored in a context ErrContextKeyNotStored = errors.New("no value in Context for contextKey") )
Functions ¶
func GetOverrideTimeout ¶
GetOverrideTimeout returns the override timeout value from a context if it's been stored and type-checks it. If either of these operations fail, it returns an error
func GetProperTimeout ¶
func GetProperTimeout(ctx context.Context, defaultDuration string) (timeout time.Duration, defaultUsed bool, err error)
GetProperTimeoutFromContext takes a context and a default duration, and tries to see if the context is holding an overrideTimeout key. If it finds an overrideTimeout key, it returns the corresponding time.Duration. Otherwise, it will parse the defaultDuration string and return a time.Duration from that, if possible. If the latter happens, the returned bool will be set to true, indicating that a the passed in default was used.
func GetVerbose ¶
GetVerbose returns the type-checked value of the verbose contextKey from a context if it has been stored. If there was an issue retrieving the value from the verbose contextKey in the context, an error is returned
func WithOverrideTimeout ¶
WithOverrideTimeout takes a parent context and returns a new context with an override timeout set
Types ¶
This section is empty.