interceptors

package
v2.0.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 69

Documentation

Overview

interceptor is an internal package used by higher level middlewares. It allows injecting custom code in various places of the gRPC lifecycle.

This particular package is intended for use by other middleware, metric, logging or otherwise. This allows code to be shared between different implementations.

Index

Constants

This section is empty.

Variables

Functions

func FullMethod

func FullMethod(service, method string) string

func StreamClientInterceptor

func StreamClientInterceptor(reportable ClientReportable) grpc.StreamClientInterceptor

StreamClientInterceptor is a gRPC client-side interceptor that provides reporting for Stream RPCs.

func StreamServerInterceptor

func StreamServerInterceptor(reportable ServerReportable) grpc.StreamServerInterceptor

StreamServerInterceptor is a gRPC server-side interceptor that provides reporting for Streaming RPCs.

func UnaryClientInterceptor

func UnaryClientInterceptor(reportable ClientReportable) grpc.UnaryClientInterceptor

UnaryClientInterceptor is a gRPC client-side interceptor that provides reporting for Unary RPCs.

func UnaryServerInterceptor

func UnaryServerInterceptor(reportable ServerReportable) grpc.UnaryServerInterceptor

UnaryServerInterceptor is a gRPC server-side interceptor that provides reporting for Unary RPCs.

Types

type ClientReportable

type ClientReportable interface {
	ClientReporter(ctx context.Context, reqProtoOrNil interface{}, typ GRPCType, service string, method string) (Reporter, context.Context)
}

type GRPCType

type GRPCType string
const (
	Unary        GRPCType = "unary"
	ClientStream GRPCType = "client_stream"
	ServerStream GRPCType = "server_stream"
	BidiStream   GRPCType = "bidi_stream"
)

type NoopReporter

type NoopReporter struct{}

func (NoopReporter) PostCall

func (NoopReporter) PostCall(error, time.Duration)

func (NoopReporter) PostMsgReceive

func (NoopReporter) PostMsgReceive(interface{}, error, time.Duration)

func (NoopReporter) PostMsgSend

func (NoopReporter) PostMsgSend(interface{}, error, time.Duration)

type Reporter

type Reporter interface {
	PostCall(err error, rpcDuration time.Duration)

	PostMsgSend(reqProto interface{}, err error, sendDuration time.Duration)
	PostMsgReceive(replyProto interface{}, err error, recvDuration time.Duration)
}

type ServerReportable

type ServerReportable interface {
	ServerReporter(ctx context.Context, reqProtoOrNil interface{}, typ GRPCType, service string, method string) (Reporter, context.Context)
}

Directories

Path Synopsis
logging is a "parent" package for gRPC logging middlewares.
logging is a "parent" package for gRPC logging middlewares.
`ratelimit` a generic server-side ratelimit middleware for gRPC.
`ratelimit` a generic server-side ratelimit middleware for gRPC.
`recovery` are interceptors that recover from gRPC handler panics.
`recovery` are interceptors that recover from gRPC handler panics.
`retry` provides client-side request retry logic for gRPC.
`retry` provides client-side request retry logic for gRPC.
`tags` adds a Tag object to the context that can be used by other middleware to add context about a request.
`tags` adds a Tag object to the context that can be used by other middleware to add context about a request.
tracing is a "parent" package for gRPC logging middlewares.
tracing is a "parent" package for gRPC logging middlewares.
`validator` is a generic request contents validator server-side middleware for gRPC.
`validator` is a generic request contents validator server-side middleware for gRPC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL