Documentation ¶
Overview ¶
Package interceptors provides a common set of interceptors which are used in Coldbrew
Almost all of these interceptors are reusable and can be used in any other project using grpc.
Index ¶
- Variables
- func AddStreamClientInterceptor(ctx context.Context, i ...grpc.StreamClientInterceptor)
- func AddStreamServerInterceptor(ctx context.Context, i ...grpc.StreamServerInterceptor)
- func AddUnaryClientInterceptor(ctx context.Context, i ...grpc.UnaryClientInterceptor)
- func AddUnaryServerInterceptor(ctx context.Context, i ...grpc.UnaryServerInterceptor)
- func DebugLoggingInterceptor() grpc.UnaryServerInterceptor
- func DefaultClientInterceptor(defaultOpts ...interface{}) grpc.UnaryClientInterceptor
- func DefaultClientInterceptors(defaultOpts ...interface{}) []grpc.UnaryClientInterceptor
- func DefaultClientStreamInterceptor(defaultOpts ...interface{}) grpc.StreamClientInterceptor
- func DefaultClientStreamInterceptors(defaultOpts ...interface{}) []grpc.StreamClientInterceptor
- func DefaultInterceptors() []grpc.UnaryServerInterceptor
- func DefaultStreamInterceptors() []grpc.StreamServerInterceptor
- func DoHTTPtoGRPC(ctx context.Context, svr interface{}, ...) (interface{}, error)
- func FilterMethodsFunc(ctx context.Context, fullMethodName string) bool
- func GRPCClientInterceptor(options ...grpc_opentracing.Option) grpc.UnaryClientInterceptor
- func HystrixClientInterceptor(defaultOpts ...grpc.CallOption) grpc.UnaryClientInterceptor
- func NRHttpTracer(pattern string, h http.HandlerFunc) (string, http.HandlerFunc)
- func NewRelicClientInterceptor() grpc.UnaryClientInterceptor
- func NewRelicInterceptor() grpc.UnaryServerInterceptor
- func OptionsInterceptor() grpc.UnaryServerInterceptor
- func PanicRecoveryInterceptor() grpc.UnaryServerInterceptor
- func ResponseTimeLoggingInterceptor(ff FilterFunc) grpc.UnaryServerInterceptor
- func ResponseTimeLoggingStreamInterceptor() grpc.StreamServerInterceptor
- func ServerErrorInterceptor() grpc.UnaryServerInterceptor
- func ServerErrorStreamInterceptor() grpc.StreamServerInterceptor
- func SetFilterFunc(ctx context.Context, ff FilterFunc)
- func TraceIdInterceptor() grpc.UnaryServerInterceptor
- func UseColdBrewClientInterceptors(ctx context.Context, flag bool)
- func UseColdBrewServerInterceptors(ctx context.Context, flag bool)
- func WithHystrix() clientOption
- func WithHystrixName(name string) clientOption
- func WithoutHystrix() clientOption
- type FilterFunc
Constants ¶
This section is empty.
Variables ¶
var ( //FilterMethods is the list of methods that are filtered by default FilterMethods = []string{"healthcheck", "readycheck", "serverreflectioninfo"} )
Functions ¶
func AddStreamClientInterceptor ¶ added in v0.1.5
func AddStreamClientInterceptor(ctx context.Context, i ...grpc.StreamClientInterceptor)
AddStreamClientInterceptor adds a server interceptor to default server interceptors
func AddStreamServerInterceptor ¶ added in v0.1.5
func AddStreamServerInterceptor(ctx context.Context, i ...grpc.StreamServerInterceptor)
AddStreamServerInterceptor adds a server interceptor to default server interceptors
func AddUnaryClientInterceptor ¶ added in v0.1.5
func AddUnaryClientInterceptor(ctx context.Context, i ...grpc.UnaryClientInterceptor)
AddUnaryClientInterceptor adds a server interceptor to default server interceptors
func AddUnaryServerInterceptor ¶ added in v0.1.5
func AddUnaryServerInterceptor(ctx context.Context, i ...grpc.UnaryServerInterceptor)
AddUnaryServerInterceptor adds a server interceptor to default server interceptors
func DebugLoggingInterceptor ¶
func DebugLoggingInterceptor() grpc.UnaryServerInterceptor
DebugLoggingInterceptor is the interceptor that logs all request/response from a handler
func DefaultClientInterceptor ¶
func DefaultClientInterceptor(defaultOpts ...interface{}) grpc.UnaryClientInterceptor
DefaultClientInterceptor are the set of default interceptors that should be applied to all client calls
func DefaultClientInterceptors ¶
func DefaultClientInterceptors(defaultOpts ...interface{}) []grpc.UnaryClientInterceptor
DefaultClientInterceptors are the set of default interceptors that should be applied to all client calls
func DefaultClientStreamInterceptor ¶ added in v0.1.4
func DefaultClientStreamInterceptor(defaultOpts ...interface{}) grpc.StreamClientInterceptor
DefaultClientStreamInterceptor are the set of default interceptors that should be applied to all stream client calls
func DefaultClientStreamInterceptors ¶ added in v0.1.4
func DefaultClientStreamInterceptors(defaultOpts ...interface{}) []grpc.StreamClientInterceptor
DefaultClientStreamInterceptors are the set of default interceptors that should be applied to all stream client calls
func DefaultInterceptors ¶
func DefaultInterceptors() []grpc.UnaryServerInterceptor
DefaultInterceptors are the set of default interceptors that are applied to all coldbrew methods
func DefaultStreamInterceptors ¶
func DefaultStreamInterceptors() []grpc.StreamServerInterceptor
DefaultStreamInterceptors are the set of default interceptors that should be applied to all coldbrew streams
func DoHTTPtoGRPC ¶ added in v0.1.2
func DoHTTPtoGRPC(ctx context.Context, svr interface{}, handler func(ctx context.Context, req interface{}) (interface{}, error), in interface{}) (interface{}, error)
DoHTTPtoGRPC allows calling the interceptors when you use the Register<svc-name>HandlerServer in grpc-gateway, see example below for reference
func (s *svc) Echo(ctx context.Context, req *proto.EchoRequest) (*proto.EchoResponse, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) { return s.echo(ctx, req.(*proto.EchoRequest)) } r, e := doHTTPtoGRPC(ctx, s, handler, req) if e != nil { return nil, e.(error) } return r.(*proto.EchoResponse), nil } func (s *svc) echo(ctx context.Context, req *proto.EchoRequest) (*proto.EchoResponse, error) { .... implementation .... }
func FilterMethodsFunc ¶
FilterMethodsFunc is the default implementation of Filter function
func GRPCClientInterceptor ¶
func GRPCClientInterceptor(options ...grpc_opentracing.Option) grpc.UnaryClientInterceptor
GRPCClientInterceptor is the interceptor that intercepts all cleint requests and adds tracing info to them
func HystrixClientInterceptor ¶
func HystrixClientInterceptor(defaultOpts ...grpc.CallOption) grpc.UnaryClientInterceptor
HystrixClientInterceptor is the interceptor that intercepts all client requests and adds hystrix info to them
func NRHttpTracer ¶
func NRHttpTracer(pattern string, h http.HandlerFunc) (string, http.HandlerFunc)
NRHttpTracer adds newrelic tracing to this http function
func NewRelicClientInterceptor ¶
func NewRelicClientInterceptor() grpc.UnaryClientInterceptor
NewRelicClientInterceptor intercepts all client actions and reports them to newrelic
func NewRelicInterceptor ¶
func NewRelicInterceptor() grpc.UnaryServerInterceptor
NewRelicInterceptor intercepts all server actions and reports them to newrelic
func OptionsInterceptor ¶
func OptionsInterceptor() grpc.UnaryServerInterceptor
func PanicRecoveryInterceptor ¶
func PanicRecoveryInterceptor() grpc.UnaryServerInterceptor
func ResponseTimeLoggingInterceptor ¶
func ResponseTimeLoggingInterceptor(ff FilterFunc) grpc.UnaryServerInterceptor
ResponseTimeLoggingInterceptor logs response time for each request on server
func ResponseTimeLoggingStreamInterceptor ¶
func ResponseTimeLoggingStreamInterceptor() grpc.StreamServerInterceptor
ResponseTimeLoggingStreamInterceptor logs response time for stream RPCs.
func ServerErrorInterceptor ¶
func ServerErrorInterceptor() grpc.UnaryServerInterceptor
ServerErrorInterceptor intercepts all server actions and reports them to error notifier
func ServerErrorStreamInterceptor ¶
func ServerErrorStreamInterceptor() grpc.StreamServerInterceptor
ServerErrorStreamInterceptor intercepts server errors for stream RPCs and reports them to the error notifier.
func SetFilterFunc ¶
func SetFilterFunc(ctx context.Context, ff FilterFunc)
SetFilterFunc sets the default filter function to be used by interceptors
func TraceIdInterceptor ¶ added in v0.1.2
func TraceIdInterceptor() grpc.UnaryServerInterceptor
TraceIdInterceptor allows injecting trace id from request objects
func UseColdBrewClientInterceptors ¶ added in v0.1.5
UseColdBrewClientInterceptors allows enabling/disabling coldbrew client interceptors
when set to false, the coldbrew client interceptors will not be used
func UseColdBrewServerInterceptors ¶ added in v0.1.5
UseColdBrewServerInterceptors allows enabling/disabling coldbrew server interceptors
when set to false, the coldbrew server interceptors will not be used
func WithHystrixName ¶
func WithHystrixName(name string) clientOption
WithHystrixName changes the hystrix name to be used in the client interceptors