requestid

package
v1.27.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

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

RequestIDMetadataKey is the key in which request IDs are passed to metadata.

Variables

This section is empty.

Functions

func GenerateRequestID added in v1.27.0

func GenerateRequestID() string

GenerateRequestID generates a new request ID.

func GetOrGenerateRequestID added in v1.27.0

func GetOrGenerateRequestID(ctx context.Context) (string, context.Context)

GetOrGenerateRequestID returns the request ID found in the given context. If not, a new request ID is generated and added to the returned context.

func StreamServerInterceptor

func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new interceptor which handles request IDs according to the provided options.

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new interceptor which handles request IDs according to the provided options.

Types

type IDGenerator

type IDGenerator func() string

IDGenerator functions are used to generate request IDs if a new one is needed.

type Option

type Option func(*handleRequestID)

Option instances control how the middleware is initialized.

func GenerateIfMissing

func GenerateIfMissing(enable bool) Option

GenerateIfMissing will instruct the middleware to create a request ID if one isn't already on the incoming request.

default: false

func WithIDGenerator

func WithIDGenerator(genFunc IDGenerator) Option

WithIDGenerator gives the middleware a function to use for generating requestIDs.

default: 32 character hex string

Jump to

Keyboard shortcuts

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