Documentation ¶
Index ¶
- func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.StreamClientInterceptor
- func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
- func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor
- func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
- func GetClientIp(ctx context.Context) (string, error)
- func Limit(limiter Limiter) grpc.UnaryServerInterceptor
- func RequestInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (res interface{}, err error)
- func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
- func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
- type Limiter
- type MockPassLimiter
- type RateLimitWare
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainStreamClient ¶
func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.StreamClientInterceptor
ChainStreamClient creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainStreamClient(one, two, three) will execute one before two before three.
func ChainStreamServer ¶
func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
ChainStreamServer creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three. If you want to pass context between interceptors, use WrapServerStream.
func ChainUnaryClient ¶
func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor
ChainUnaryClient creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryClient(one, two, three) will execute one before two before three.
func ChainUnaryServer ¶
func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
ChainUnaryServer creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.
func Limit ¶
func Limit(limiter Limiter) grpc.UnaryServerInterceptor
func RequestInterceptor ¶
func RequestInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (res interface{}, err error)
request interceptor 请求拦截器,记录请求的基本信息
func WithStreamServerChain ¶
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
WithStreamServerChain is a grpc.Server config option that accepts multiple stream interceptors. Basically syntactic sugar.
func WithUnaryServerChain ¶
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
Chain creates a single interceptor out of a chain of many interceptors.
WithUnaryServerChain is a grpc.Server config option that accepts multiple unary interceptors. Basically syntactic sugar.
Types ¶
type Limiter ¶
type Limiter interface {
Limit() bool
}
Limiter defines the interface to perform request rate limiting. If Limit function return true, the request will be rejected. Otherwise, the request will pass.
type MockPassLimiter ¶
type MockPassLimiter struct{}
func (*MockPassLimiter) Limit ¶
func (*MockPassLimiter) Limit() bool
type RateLimitWare ¶
type RateLimitWare struct { }