requestid

package
v0.3.63 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataKey = "x-request-id"

Request IDs are embedded in HTTP headers using this key. This is the standard key used for request Ids. For example, opentelemetry uses the same one.

Variables

This section is empty.

Functions

func AddToIncomingContext

func AddToIncomingContext(ctx context.Context, id string) (context.Context, bool)

AddToIncomingContext returns a new context derived from ctx that is annotated with an Id. The Id is stored in the request gRPC metadata. If ctx already has an Id, it is overwritten. The second return value is true if the operation was successful.

func FromContext

func FromContext(ctx context.Context) (string, bool)

FromContext returns the request Id embedded in gRPC metadata stored in a context, if one is available. The second return value is true if the operation was successful.

func FromContextOrMissing

func FromContextOrMissing(ctx context.Context) string

FromContextOrMissing returns the request Id embedded in gRPC metadata stored in a context, if one is available. If none is available, the string "missing" is returned.

func StreamServerInterceptor

func StreamServerInterceptor(replace bool) grpc.StreamServerInterceptor

StreamServerInterceptor returns an interceptor that annotates incoming gRPC requests with an Id. Ids are stored in the gRPC request metadata and are generated using github.com/renstrom/shortuuid. If replace is false, this is only done for requests that do not already have an Id.

func UnaryServerInterceptor

func UnaryServerInterceptor(replace bool) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns an interceptor that annotates incoming gRPC requests with an Id. Ids are stored in the gRPC request metadata and are generated using github.com/renstrom/shortuuid. If replace is false, this is only done for requests that do not already have an Id.

Types

This section is empty.

Jump to

Keyboard shortcuts

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