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
- func ContextWithMetadata(ctx context.Context) (context.Context, map[string][]string)
- func ContextWithMetadataUnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func ContextWithTimeoutIfNoDeadline(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.