Documentation
¶
Overview ¶
Package grpcserver provides gRPC server interceptors that integrate with LabKit v2's correlation and logging packages. It is the gRPC counterpart to package httpserver.
Chain the correlation interceptors outermost so every later interceptor and the service handler observe the correlation ID via correlation.ExtractFromContext:
srv := grpc.NewServer( grpc.ChainUnaryInterceptor(grpcserver.UnaryServerCorrelationInterceptor()), grpc.ChainStreamInterceptor(grpcserver.StreamServerCorrelationInterceptor()), )
Index ¶
Constants ¶
const CorrelationIDHeader = "x-gitlab-correlation-id"
CorrelationIDHeader is the incoming metadata key read for a caller-supplied correlation ID, and the response header key the resolved ID is echoed back on. It matches LabKit v1's gRPC header so v1 clients propagate into v2 servers unchanged. gRPC metadata keys are case-insensitive.
Variables ¶
This section is empty.
Functions ¶
func StreamServerCorrelationInterceptor ¶
func StreamServerCorrelationInterceptor() grpc.StreamServerInterceptor
StreamServerCorrelationInterceptor is the stream equivalent of UnaryServerCorrelationInterceptor. The handler receives a wrapped stream whose Context carries the correlation ID.
func UnaryServerCorrelationInterceptor ¶
func UnaryServerCorrelationInterceptor() grpc.UnaryServerInterceptor
UnaryServerCorrelationInterceptor returns a unary server interceptor that reads the correlation ID from incoming metadata, validates it with correlation.Sanitize (generating a UUID when absent or invalid), injects it into the handler context, and echoes it back as a response header.
Chain it outermost so later interceptors and the handler see the ID.
Types ¶
This section is empty.