contextutils

package
v0.414.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNoCacheIndicatorPresent = errors.New("no cache indicator present in given contest")
View Source
var ErrorNoChangeIndicatorPresent = errors.New("no change indicator present in given contest")

Functions

func ContextSilent

func ContextSilent() (ctx context.Context)

func ContextVerbose

func ContextVerbose() (ctx context.Context)

func GetLogLinePrefixFromCtx

func GetLogLinePrefixFromCtx(ctx context.Context) (logLinePrefix string)

func GetVerboseFromContext

func GetVerboseFromContext(ctx context.Context) (verbose bool)

func GetVerbosityContextByBool

func GetVerbosityContextByBool(verbose bool) (ctx context.Context)

func GetVerbosityContextByCobraCmd

func GetVerbosityContextByCobraCmd(cmd *cobra.Command) (ctx context.Context)

func IsCacheIndicatorPresent added in v0.295.0

func IsCacheIndicatorPresent(ctx context.Context) bool

func IsCachedResult added in v0.295.0

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

true means the returned result bases on cached data, false means no cache was involved. If ctx has no CacheInidicator as Value it an error is returned.

func IsChangeIndicatorPresent added in v0.353.0

func IsChangeIndicatorPresent(ctx context.Context) bool

func IsChanged added in v0.353.0

func IsChanged(ctx context.Context) bool

func IsChangedResult added in v0.353.0

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

true means the returned result bases on change data, false means no cache was involved. If ctx has no ChangeInidicator as Value it an error is returned.

func SetCacheIndicator added in v0.295.0

func SetCacheIndicator(ctx context.Context, cached bool)

Use this to set the cache indication. Set the parameter 'cached' to true to indiacte the given result bases on caching.

If no cache indicator is present or ctx is nil the ctx stays untouched. This allows to use SetCahceIndicator wherever you want but it's only changing ctx if requested by a ctx with change indicator.

func SetChangeIndicator added in v0.353.0

func SetChangeIndicator(ctx context.Context, change bool)

Use this to set the cache indication. Set the parameter 'change' to true to indiacte the given result bases on caching.

If no cache indicator is present or ctx is nil the ctx stays untouched. This allows to use SetCahceIndicator wherever you want but it's only changing ctx if requested by a ctx with change indicator.

func WithCacheIndicator added in v0.295.0

func WithCacheIndicator(ctx context.Context) context.Context

Get a child context containing an cache indicator which can indicate if a result bases on cached data or not.

func WithChangeIndicator added in v0.353.0

func WithChangeIndicator(ctx context.Context) context.Context

Get a child context containing an cache indicator which can indicate if a result bases on change data or not.

func WithLogLinePrefix

func WithLogLinePrefix(ctx context.Context, logLinePrefix string) (ctxWithLogLinePrefix context.Context)

func WithSilent added in v0.315.0

func WithSilent(ctx context.Context) context.Context

Returns a child context with verbosity disabled.

func WithVerbose added in v0.315.0

func WithVerbose(ctx context.Context) context.Context

Returns a child context with verbosity enabled.

func WithVerbosityContextByBool

func WithVerbosityContextByBool(ctx context.Context, verbose bool) (ctxWithVerbosity context.Context)

Returns a child context of ctx with verbosity enabled according to `verbose`. If ctx is nil a new context with verbosity set is returned.

Types

type CacheIndicator added in v0.295.0

type CacheIndicator struct {
	// true indicates you received a cached result.
	CachedResult bool
}

type ChangeIndicator added in v0.353.0

type ChangeIndicator struct {
	// true indicates you received a change result.
	ChangedResult bool
}

Jump to

Keyboard shortcuts

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