import "github.com/go-coldbrew/interceptors"
Almost all of these interceptors are reusable and can be used in any other project using grpc.
- 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{}, handler func(ctx context.Context, req interface{}) (interface{}, error), in 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)
- type FilterFunc
var (
//FilterMethods is the list of methods that are filtered by default
FilterMethods = []string{"healthcheck", "readycheck", "serverreflectioninfo"}
)
func AddStreamClientInterceptor(ctx context.Context, i ...grpc.StreamClientInterceptor)
AddStreamClientInterceptor adds a server interceptor to default server interceptors
func AddStreamServerInterceptor(ctx context.Context, i ...grpc.StreamServerInterceptor)
AddStreamServerInterceptor adds a server interceptor to default server interceptors
func AddUnaryClientInterceptor(ctx context.Context, i ...grpc.UnaryClientInterceptor)
AddUnaryClientInterceptor adds a server interceptor to default server interceptors
func AddUnaryServerInterceptor(ctx context.Context, i ...grpc.UnaryServerInterceptor)
AddUnaryServerInterceptor adds a server interceptor to default server interceptors
func DebugLoggingInterceptor() grpc.UnaryServerInterceptor
DebugLoggingInterceptor is the interceptor that logs all request/response from a handler
func DefaultClientInterceptor(defaultOpts ...interface{}) grpc.UnaryClientInterceptor
DefaultClientInterceptor are the set of default interceptors that should be applied to all client calls
func DefaultClientInterceptors(defaultOpts ...interface{}) []grpc.UnaryClientInterceptor
DefaultClientInterceptors are the set of default interceptors that should be applied to all client calls
func DefaultClientStreamInterceptor(defaultOpts ...interface{}) grpc.StreamClientInterceptor
DefaultClientStreamInterceptor are the set of default interceptors that should be applied to all stream client calls
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() []grpc.StreamServerInterceptor
DefaultStreamInterceptors are the set of default interceptors that should be applied to all coldbrew streams
func DoHTTPtoGRPC
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
func FilterMethodsFunc(ctx context.Context, fullMethodName string) bool
FilterMethodsFunc is the default implementation of Filter function
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(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() 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() grpc.UnaryServerInterceptor
func ResponseTimeLoggingInterceptor(ff FilterFunc) grpc.UnaryServerInterceptor
ResponseTimeLoggingInterceptor logs response time for each request on server
func ResponseTimeLoggingStreamInterceptor() grpc.StreamServerInterceptor
ResponseTimeLoggingStreamInterceptor logs response time for stream RPCs.
func ServerErrorInterceptor() grpc.UnaryServerInterceptor
ServerErrorInterceptor intercepts all server actions and reports them to error notifier
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
func TraceIdInterceptor() grpc.UnaryServerInterceptor
TraceIdInterceptor allows injecting trace id from request objects
func UseColdBrewClientInterceptors(ctx context.Context, flag bool)
when set to false, the coldbrew client interceptors will not be used
func UseColdBrewServerInterceptors(ctx context.Context, flag bool)
when set to false, the coldbrew server interceptors will not be used
type FilterFunc
If it returns false, the given request will not be traced.
type FilterFunc func(ctx context.Context, fullMethodName string) bool
Generated by gomarkdoc