correlation

package
v0.27.258 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const IDSize = 12

IDSize specifies a size in characters for the correlation ID

Variables

View Source
var CorrelationIDgRPCHeaderName = "x-correlation-id"

CorrelationIDgRPCHeaderName specifies default name for gRPC header

Functions

func ID

func ID(ctx context.Context) string

ID returns correlation ID from the context

func NewAuthUnaryInterceptor

func NewAuthUnaryInterceptor() grpc.UnaryServerInterceptor

NewAuthUnaryInterceptor returns grpc.UnaryServerInterceptor that identity to the context

func NewFromContext

func NewFromContext(ctx context.Context) context.Context

NewFromContext returns new Background context with Correlation ID from incoming context

func NewHandler

func NewHandler(delegate http.Handler) http.Handler

NewHandler returns a handler that will extact/add the correlationID from the request and stash them away in the request context for later handlers to use.

func WithID

func WithID(ctx context.Context) context.Context

WithID returns context with Correlation ID, if the context alread has Correlation ID, the original is returned

func WithMetaFromContext

func WithMetaFromContext(ctx context.Context) context.Context

WithMetaFromContext returns context with Correlation ID for the outgoing gRPC call

func WithMetaFromRequest

func WithMetaFromRequest(req *http.Request) context.Context

WithMetaFromRequest returns context with Correlation ID for the outgoing gRPC call

Types

type Correlator

type Correlator interface {
	CorrelationID() string
}

Correlator interface allows to provide request ID

type RequestContext

type RequestContext struct {
	ID string
}

RequestContext represents user contextual information about a request being processed by the server, it includes ID, aka Request-ID or Correlation-ID (for cross system request correlation).

func Value

func Value(ctx context.Context) *RequestContext

Value returns correlation RequestContext from the context

Jump to

Keyboard shortcuts

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