Documentation
¶
Index ¶
- Constants
- func NewMetadataCarrier(opts ...MetadataCarrierOption) *metadataCarrier
- func NewMetadataSourceCarrier(carrier Carrier, opts ...MetadataCarrierOption) *metadataSourceCarrier
- func NewRandGenerator(length int) *randGenerator
- func StreamServerInterceptor(idGenerator IdGenerator, carrier Carrier) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(idGenerator IdGenerator, carrier Carrier) grpc.UnaryServerInterceptor
- type Carrier
- type IdGenerator
- type MetadataCarrierOption
Constants ¶
View Source
const TagCorrelationID = "correlationid"
Variables ¶
This section is empty.
Functions ¶
func NewMetadataCarrier ¶
func NewMetadataCarrier(opts ...MetadataCarrierOption) *metadataCarrier
NewMetadataCarrier creates a carrier operating on gRPC metadata headers.
func NewMetadataSourceCarrier ¶
func NewMetadataSourceCarrier(carrier Carrier, opts ...MetadataCarrierOption) *metadataSourceCarrier
NewMetadataSourceCarrier returns a carrier which reads the correlation ID from metadata in case the provided carrier does not have any configured. Setting the correlation ID on the other hand only sets the underlying carrier, but does not set the metadata header.
func NewRandGenerator ¶
func NewRandGenerator(length int) *randGenerator
NewRandGenerator returns a unique ID generator of the given length.
func StreamServerInterceptor ¶
func StreamServerInterceptor(idGenerator IdGenerator, carrier Carrier) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor for propagating correlation ID.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(idGenerator IdGenerator, carrier Carrier) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for propagating correlation ID.
Types ¶
type Carrier ¶
type Carrier interface { // GetCorrelationID returns an existing correlation ID. // If the second argument is false, the interceptor attempts to set the correlation ID. // If the correlation ID is empty, the second argument should be false in order to generate a new one. GetCorrelationID(ctx context.Context) (string, bool) // SetCorrelationID sets a correlation ID in the context and returns the new context (if any). SetCorrelationID(ctx context.Context, correlationID string) context.Context }
type IdGenerator ¶
type IdGenerator interface { // Generate generates a unique string which can be used as a correlation ID. Generate() string }
type MetadataCarrierOption ¶
type MetadataCarrierOption func(*metadataCarrier)
func WithHeader ¶
func WithHeader(header string) MetadataCarrierOption
WithHeader customizes the metadata header for the correlation ID.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.