Documentation
¶
Overview ¶
Package interceptor provides interceptor types for cross-cutting concerns like authentication, logging, metrics, and tracing in RPC calls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientStream ¶
type ClientStream interface {
Send(ctx context.Context, payload []byte) error
Recv(ctx context.Context) iter.Seq[[]byte]
CloseSend() error
Close() error
Err() error
}
ClientStream is the stream interface passed to stream client interceptors.
type ClientStreamer ¶
type ClientStreamer func(ctx context.Context) (ClientStream, error)
ClientStreamer creates a client stream.
type ServerStream ¶
type ServerStream interface {
Send(payload []byte) error
Recv() iter.Seq[[]byte]
Context() context.Context
}
ServerStream is the stream interface passed to stream server interceptors.
type StreamClientInterceptor ¶
type StreamClientInterceptor func(ctx context.Context, method string, streamer ClientStreamer) (ClientStream, error)
StreamClientInterceptor intercepts streaming RPC calls on the client. It receives the method name and the streamer that creates the actual stream.
func ChainStreamClient ¶
func ChainStreamClient(interceptors ...StreamClientInterceptor) StreamClientInterceptor
ChainStreamClient chains multiple stream client interceptors into one. Interceptors are executed in the order provided.
type StreamHandler ¶
type StreamHandler func(ctx context.Context, stream ServerStream) error
StreamHandler is the handler that a stream server interceptor wraps.
type StreamServerInfo ¶
type StreamServerInfo struct {
Package string
Service string
Method string
SessionID uint32
Metadata []msgs.Metadata
RPCType msgs.RPCType
}
StreamServerInfo contains RPC metadata available to stream server interceptors.
type StreamServerInterceptor ¶
type StreamServerInterceptor func(ctx context.Context, stream ServerStream, info *StreamServerInfo, handler StreamHandler) error
StreamServerInterceptor intercepts streaming RPC calls on the server. It receives the stream, RPC info, and the next handler in the chain.
func ChainStreamServer ¶
func ChainStreamServer(interceptors ...StreamServerInterceptor) StreamServerInterceptor
ChainStreamServer chains multiple stream server interceptors into one. Interceptors are executed in the order provided.
type UnaryClientInterceptor ¶
type UnaryClientInterceptor func(ctx context.Context, method string, req []byte, invoker UnaryInvoker) ([]byte, error)
UnaryClientInterceptor intercepts synchronous RPC calls on the client. It receives the method name (in "package/service/method" format), request, and the invoker that performs the actual call.
func ChainUnaryClient ¶
func ChainUnaryClient(interceptors ...UnaryClientInterceptor) UnaryClientInterceptor
ChainUnaryClient chains multiple unary client interceptors into one. Interceptors are executed in the order provided.
type UnaryHandler ¶
UnaryHandler is the handler that a unary server interceptor wraps.
type UnaryInvoker ¶
UnaryInvoker performs the actual unary RPC call on the client side.
type UnaryServerInfo ¶
type UnaryServerInfo struct {
Package string
Service string
Method string
SessionID uint32
Metadata []msgs.Metadata
}
UnaryServerInfo contains RPC metadata available to unary server interceptors.
type UnaryServerInterceptor ¶
type UnaryServerInterceptor func(ctx context.Context, req []byte, info *UnaryServerInfo, handler UnaryHandler) ([]byte, error)
UnaryServerInterceptor intercepts synchronous RPC calls on the server. It receives the request, RPC info, and the next handler in the chain. The interceptor can modify the request, call the handler, and modify the response.
func ChainUnaryServer ¶
func ChainUnaryServer(interceptors ...UnaryServerInterceptor) UnaryServerInterceptor
ChainUnaryServer chains multiple unary server interceptors into one. Interceptors are executed in the order provided.