correlationid

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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.

Directories

Path Synopsis
carrier
internal
mocks
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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