Documentation ¶
Index ¶
- Constants
- func Interceptors(middleware Middleware) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)
- func LogMisconfiguration(ctx context.Context, msg string)
- func StreamInterceptor(middleware Middleware) grpc.StreamServerInterceptor
- func UnaryInterceptor(middleware Middleware) grpc.UnaryServerInterceptor
- type Middleware
- func Chain(middleware ...Middleware) Middleware
- func Funcs(preprocess PreprocessFunc, postprocess PostprocessFunc) Middleware
- func Postprocess(fn PostprocessFunc) Middleware
- func Preprocess(fn PreprocessFunc) Middleware
- func WithLogger(log logrus.FieldLogger) Middleware
- func WithMetrics(metrics telemetry.Metrics) Middleware
- type PostprocessFunc
- type PreprocessFunc
Constants ¶
const ( WorkloadAPIServiceName = "SpiffeWorkloadAPI" WorkloadAPIServiceShortName = "WorkloadAPI" EnvoySDSv2ServiceName = "envoy.service.discovery.v2.SecretDiscoveryService" EnvoySDSv2ServiceShortName = "SDS.v2" EnvoySDSv3ServiceName = "envoy.service.secret.v3.SecretDiscoveryService" EnvoySDSv3ServiceShortName = "SDS.v3" HealthServiceName = "grpc.health.v1.Health" HealthServiceShortName = "Health" )
Variables ¶
This section is empty.
Functions ¶
func Interceptors ¶
func Interceptors(middleware Middleware) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)
func LogMisconfiguration ¶
LogMisconfiguration logs a misconfiguration for the RPC. It assumes that the context has been embellished with the names for the RPC. This method should not be called under normal operation and only when there is an implementation bug. As such there is no attempt at a time/space efficient implementation. In any case, the number of distinct misconfiguration messages intersected with the number of RPCs should not produce any amount of real memory use. Contention on the global mutex should also be reasonable.
func StreamInterceptor ¶
func StreamInterceptor(middleware Middleware) grpc.StreamServerInterceptor
func UnaryInterceptor ¶
func UnaryInterceptor(middleware Middleware) grpc.UnaryServerInterceptor
Types ¶
type Middleware ¶
type Middleware interface { // Preprocess is invoked before the gRPC handler is called. It returns a // (possibly modified) context that is passed into the handler, which // should either be the context passed into the function or one derived // from it. If the function returns an error, the gRPC method fails. // req passes the request object for unary interceptors and nil for // stream interceptors Preprocess(ctx context.Context, fullMethod string, req interface{}) (context.Context, error) // Postprocess is invoked after the handler is called, or if downstream // middleware returns an error from Preprocess. The function is passed an // error that was returned from the handler or a downstream middleware // during preprocessing. The handlerInvoked boolean, if true, indicates // that the handler was executed. If false, then the call failed during // preprocessing. Postprocess(ctx context.Context, fullMethod string, handlerInvoked bool, rpcErr error) }
func Chain ¶
func Chain(middleware ...Middleware) Middleware
Chain chains together a series of middleware. The middleware is called in order during preprocessing and in reverse order for postprocessing. The context returned by each Middleware during preprocessing is passed into subsequent middlewares
func Funcs ¶
func Funcs(preprocess PreprocessFunc, postprocess PostprocessFunc) Middleware
Funcs constructs a Middleware from a pair of functions, one for preprocessing, one for postprocessing.
func Postprocess ¶
func Postprocess(fn PostprocessFunc) Middleware
Postprocess creates a middleware from a function that does postprocessing only.
func Preprocess ¶
func Preprocess(fn PreprocessFunc) Middleware
Preprocess creates a middleware from a function that does preprocessing only.
func WithLogger ¶
func WithLogger(log logrus.FieldLogger) Middleware
WithLogger returns logging middleware that provides a per-rpc logger with some initial fields set. If unset, it also provides name metadata to the handler context.
func WithMetrics ¶
func WithMetrics(metrics telemetry.Metrics) Middleware
WithMetrics adds per-call metrics to each RPC call. It emits both a call counter and sample with the call timing. RPC handlers can add their own labels to be attached to the per-call metrics via the rpccontext.AddMetricsLabel function. If unset, it also provides name metadata on to the handler context.