Documentation ¶
Overview ¶
Package servicecontext performs context values read/write, generally through server or client wrappers
Index ¶
- Variables
- func ApplyGRPCIncomingContextModifiers(ctx context.Context) (ct context.Context, modified bool, er error)
- func ApplyGRPCOutgoingContextModifiers(ctx context.Context) (ct context.Context)
- func ApplyHTTPIncomingContextModifiers(r *http.Request) (*http.Request, error)
- func CellsMetadataIncomingContext(ctx context.Context) (context.Context, bool, error)
- func ClientConnIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
- func CodeFromHTTPStatus(status int) codes.Code
- func DetectedLanguages(ctx context.Context) []string
- func ErrorFormatStreamClientInterceptor() grpc.StreamClientInterceptor
- func ErrorFormatStreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func ErrorFormatUnaryClientInterceptor() grpc.UnaryClientInterceptor
- func ErrorFormatUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func ErrorNoMatchedRouteRetryStreamClientInterceptor() grpc.StreamClientInterceptor
- func ErrorNoMatchedRouteRetryUnaryClientInterceptor() grpc.UnaryClientInterceptor
- func FromGRPC(er error) error
- func GrpcClientStatsHandler(ctx context.Context) (oo []grpc.DialOption)
- func GrpcServerStatsHandler(ctx context.Context) (oo []grpc.ServerOption)
- func GrpcStreamClientInterceptors() []grpc.StreamClientInterceptor
- func GrpcStreamServerInterceptors(rootContext context.Context) []grpc.StreamServerInterceptor
- func GrpcUnaryClientInterceptors() []grpc.UnaryClientInterceptor
- func GrpcUnaryServerInterceptors(rootContext context.Context) []grpc.UnaryServerInterceptor
- func HttpContextWrapper(svcContext context.Context, h http.Handler) http.Handler
- func HttpMetaFromGrpcContext(ctx context.Context, name string) (string, bool)
- func HttpRequestInfoToMetadata(ctx context.Context, req *http.Request) context.Context
- func HttpTracingMiddleware(operation string) func(h http.Handler) http.Handler
- func HttpWrapperMeta(h http.Handler) http.Handler
- func HttpWrapperMetrics(h http.Handler) http.Handler
- func MetricsStreamServerInterceptor() grpc.StreamServerInterceptor
- func MetricsUnaryServerInterceptor() grpc.UnaryServerInterceptor
- func RegisterModifier(m any)
- func RegisterStatsHandler(h statsHandlers)
- func RegistryIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
- func ServiceIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
- func SpanFromContext(ctx context.Context) trace.SpanContext
- func TargetNameToServiceNameContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
- func ToGRPC(er error) error
- func WebIncomingContextMiddleware(ct context.Context, endpoint string, serviceContextKey any, srv server.Server, ...) http.Handler
- func WithDetectedLanguages(ctx context.Context, ll []string) context.Context
- func WrapErrorHandlerToRoute(handler func(req *restful.Request, rsp *restful.Response) error) func(req *restful.Request, rsp *restful.Response)
- type HttpContextModifier
- type ProtoEntityReaderWriter
- type ServiceRetriever
Constants ¶
This section is empty.
Variables ¶
var HandledError = errors.RegisterBaseSentinel(errors.CellsError, "handled")
Functions ¶
func ClientConnIncomingContext ¶
func ClientConnIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
ClientConnIncomingContext adds the ClientConn to context
func CodeFromHTTPStatus ¶
CodeFromHTTPStatus converts an HTTP response status into the corresponding gRPC error code.
func DetectedLanguages ¶
DetectedLanguages reads languages from context
func ErrorFormatStreamClientInterceptor ¶
func ErrorFormatStreamClientInterceptor() grpc.StreamClientInterceptor
func ErrorFormatStreamInterceptor ¶
func ErrorFormatStreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
func ErrorFormatUnaryClientInterceptor ¶
func ErrorFormatUnaryClientInterceptor() grpc.UnaryClientInterceptor
func ErrorFormatUnaryInterceptor ¶
func ErrorFormatUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func ErrorNoMatchedRouteRetryStreamClientInterceptor ¶
func ErrorNoMatchedRouteRetryStreamClientInterceptor() grpc.StreamClientInterceptor
func ErrorNoMatchedRouteRetryUnaryClientInterceptor ¶
func ErrorNoMatchedRouteRetryUnaryClientInterceptor() grpc.UnaryClientInterceptor
func GrpcClientStatsHandler ¶
func GrpcClientStatsHandler(ctx context.Context) (oo []grpc.DialOption)
func GrpcServerStatsHandler ¶
func GrpcServerStatsHandler(ctx context.Context) (oo []grpc.ServerOption)
func GrpcStreamClientInterceptors ¶
func GrpcStreamClientInterceptors() []grpc.StreamClientInterceptor
GrpcStreamClientInterceptors returns a list of grpc.StreamClientInterceptor
func GrpcStreamServerInterceptors ¶
func GrpcStreamServerInterceptors(rootContext context.Context) []grpc.StreamServerInterceptor
GrpcStreamServerInterceptors returns a list of grpc.StreamServerInterceptor
func GrpcUnaryClientInterceptors ¶
func GrpcUnaryClientInterceptors() []grpc.UnaryClientInterceptor
GrpcUnaryClientInterceptors returns a list of grpc.UnaryClientInterceptor
func GrpcUnaryServerInterceptors ¶
func GrpcUnaryServerInterceptors(rootContext context.Context) []grpc.UnaryServerInterceptor
GrpcUnaryServerInterceptors returns a list of grpc.UnaryServerInterceptor
func HttpContextWrapper ¶
func HttpMetaFromGrpcContext ¶
HttpMetaFromGrpcContext extracts metadata from context that may have been passed along across services (meta name may be lowered cased)
func HttpRequestInfoToMetadata ¶
HttpRequestInfoToMetadata extracts as much HTTP metadata as possible and stores it in the context as metadata.
func HttpTracingMiddleware ¶
HttpTracingMiddleware enabled tracing on HTTP server
func HttpWrapperMeta ¶
HttpWrapperMeta extracts data from the request and puts it in a context Metadata field.
func MetricsStreamServerInterceptor ¶
func MetricsStreamServerInterceptor() grpc.StreamServerInterceptor
func MetricsUnaryServerInterceptor ¶
func MetricsUnaryServerInterceptor() grpc.UnaryServerInterceptor
func RegisterStatsHandler ¶
func RegisterStatsHandler(h statsHandlers)
func RegistryIncomingContext ¶
func RegistryIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
RegistryIncomingContext injects the registry in context
func ServiceIncomingContext ¶
func SpanFromContext ¶
func SpanFromContext(ctx context.Context) trace.SpanContext
SpanFromContext reads trace.SpanContext from context
func TargetNameToServiceNameContext ¶
func TargetNameToServiceNameContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)
TargetNameToServiceNameContext extracts service name from grpc meta "targetname" and inject it in the context
func WithDetectedLanguages ¶
WithDetectedLanguages passes the languages in context
Types ¶
type ProtoEntityReaderWriter ¶
type ProtoEntityReaderWriter struct {
// contains filtered or unexported fields
}
ProtoEntityReaderWriter can read and write values using an encoding such as JSON,XML.
func (*ProtoEntityReaderWriter) Read ¶
func (e *ProtoEntityReaderWriter) Read(req *restful.Request, v interface{}) error
Read a serialized version of the value from the request. The Request may have a decompressing reader. Depends on Content-Encoding.
func (*ProtoEntityReaderWriter) Write ¶
func (e *ProtoEntityReaderWriter) Write(resp *restful.Response, status int, v interface{}) error
Write a serialized version of the value on the response. The Response may have a compressing writer. Depends on Accept-Encoding. status should be a valid Http Status code
type ServiceRetriever ¶
type ServiceRetriever interface {
ServiceName() string
}