correlation

package
v0.37.403 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 12 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 NewStreamServerInterceptor added in v0.33.319

func NewStreamServerInterceptor() grpc.StreamServerInterceptor

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, on wire or in memory. Both Incoming and Outgoing metadata are created out of HTTP request headers with x- and grpc- prefixes.

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