contextStore

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GetOverrideTimeout(ctx context.Context) (time.Duration, error)

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

func GetVerbose(ctx context.Context) (bool, error)

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

func WithOverrideTimeout(ctx context.Context, timeout time.Duration) context.Context

WithOverrideTimeout takes a parent context and returns a new context with an override timeout set

func WithVerbose

func WithVerbose(ctx context.Context) context.Context

WithVerbose wraps a context with a verbose=true value

Types

This section is empty.

Jump to

Keyboard shortcuts

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