Documentation ¶
Index ¶
- Constants
- func AddToIncomingContext(ctx context.Context, id string) (context.Context, bool)
- func FromContext(ctx context.Context) (string, bool)
- func FromContextOrMissing(ctx context.Context) string
- func StreamServerInterceptor(replace bool) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(replace bool) grpc.UnaryServerInterceptor
Constants ¶
const MetadataKey = "x-request-id"
MetadataKey is the HTTP header key using this key we use to store request ids. This is the standard key used for request Ids. For example, opentelemetry uses the same one.
Variables ¶
This section is empty.
Functions ¶
func AddToIncomingContext ¶
AddToIncomingContext returns a new context derived from ctx that is annotated with an Id. The Id is stored in the request gRPC metadata. If ctx already has an Id, it is overwritten. The second return value is true if the operation was successful.
func FromContext ¶
FromContext returns the request Id embedded in gRPC metadata stored in a context, if one is available. The second return value is true if the operation was successful.
func FromContextOrMissing ¶
FromContextOrMissing returns the request Id embedded in gRPC metadata stored in a context, if one is available. If none is available, the string "missing" is returned.
func StreamServerInterceptor ¶
func StreamServerInterceptor(replace bool) grpc.StreamServerInterceptor
StreamServerInterceptor returns an interceptor that annotates incoming gRPC requests with an Id. Ids are stored in the gRPC request metadata and are generated using github.com/renstrom/shortuuid. If replace is false, this is only done for requests that do not already have an Id.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(replace bool) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns an interceptor that annotates incoming gRPC requests with an Id. Ids are stored in the gRPC request metadata and are generated using github.com/renstrom/shortuuid. If replace is false, this is only done for requests that do not already have an Id.
Types ¶
This section is empty.