contextutil

package
v1.36.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetadataKeyWorkflowType is the context metadata key for workflow type
	MetadataKeyWorkflowType = "workflow-type"
	// MetadataKeyWorkflowTaskQueue is the context metadata key for workflow task queue
	MetadataKeyWorkflowTaskQueue = "workflow-task-queue"
)

Variables

This section is empty.

Functions

func ContextHasMetadata

func ContextHasMetadata(ctx context.Context) bool

ContextHasMetadata returns true if the context has metadata support. This can be used to debug whether a context has been properly initialized with metadata.

func ContextMetadataGet

func ContextMetadataGet(ctx context.Context, key string) (any, bool)

ContextMetadataGet retrieves a metadata value from the context.

func ContextMetadataGetAll

func ContextMetadataGetAll(ctx context.Context) map[string]any

ContextMetadataGetAll retrieves all metadata from the context as a map copy.

func ContextMetadataSet

func ContextMetadataSet(ctx context.Context, key string, value any) bool

ContextMetadataSet sets a metadata key-value pair in the context.

func WithDeadlineBuffer

func WithDeadlineBuffer(
	parent context.Context,
	timeout time.Duration,
	buffer time.Duration,
) (context.Context, context.CancelFunc)

WithDeadlineBuffer returns a child context with a deadline that ensures that at least buffer amount of time remains after the child deadline expires and before the parent deadline expires. The returned context timeout is therefore <= the requested timeout. If the parent deadline itself does not allow buffer amount of time, then the returned context deadline expires immediately. Use this method to create child context when the child cannot use all of parent's deadline but instead there is a need to leave some time for parent to do some post-work.

func WithMetadataContext

func WithMetadataContext(ctx context.Context) context.Context

WithMetadataContext adds a metadata context to the given context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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