contextutils

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: AGPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

Package contextutils provides utilities for dealing with contexts such as adding and retrieving metadata to/from a context, and handling context timeouts.

Index

Constants

View Source
const (
	// MetadataContextKey is the key used to access metadata from a context with metadata.
	MetadataContextKey = contextKey("viam-metadata")

	// TimeRequestedMetadataKey is optional metadata in the gRPC response header that correlates
	// to the time right before the point cloud was captured.
	TimeRequestedMetadataKey = "viam-time-requested"

	// TimeReceivedMetadataKey is optional metadata in the gRPC response header that correlates
	// to the time right after the point cloud was captured.
	TimeReceivedMetadataKey = "viam-time-received"
)

Variables

This section is empty.

Functions

func ContextWithMetadata

func ContextWithMetadata(ctx context.Context) (context.Context, map[string][]string)

ContextWithMetadata attaches a metadata map to the context.

func ContextWithMetadataUnaryClientInterceptor

func ContextWithMetadataUnaryClientInterceptor(
	ctx context.Context,
	method string,
	req, reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

ContextWithMetadataUnaryClientInterceptor attempts to read metadata from the gRPC header and injects the metadata into the context if the caller has passed in a context with metadata.

func ContextWithTimeoutIfNoDeadline added in v0.10.0

func ContextWithTimeoutIfNoDeadline(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

ContextWithTimeoutIfNoDeadline returns a child timeout context derived from `ctx` if a deadline does not exist. Returns a cancel context and cancel func from `ctx` if deadline exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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