Documentation ¶
Index ¶
- func StreamClientCtxAugmentingInterceptor(f ContextAugmenter) grpc.StreamClientInterceptor
- func StreamClientLimitingInterceptor(limiter ClientLimiter) grpc.StreamClientInterceptor
- func StreamServerCtxAugmentingInterceptor(f ContextAugmenter) grpc.StreamServerInterceptor
- func StreamServerLimitingInterceptor(limiter ServerLimiter) grpc.StreamServerInterceptor
- func UnaryClientCtxAugmentingInterceptor(f ContextAugmenter) grpc.UnaryClientInterceptor
- func UnaryClientLimitingInterceptor(limiter ClientLimiter) grpc.UnaryClientInterceptor
- func UnaryServerCtxAugmentingInterceptor(f ContextAugmenter) grpc.UnaryServerInterceptor
- func UnaryServerLimitingInterceptor(limiter ServerLimiter) grpc.UnaryServerInterceptor
- type ClientLimiter
- type ContextAugmenter
- type ServerLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamClientCtxAugmentingInterceptor ¶
func StreamClientCtxAugmentingInterceptor(f ContextAugmenter) grpc.StreamClientInterceptor
StreamClientLimitingInterceptor returns a new stream server interceptor that augments connection context.
func StreamClientLimitingInterceptor ¶
func StreamClientLimitingInterceptor(limiter ClientLimiter) grpc.StreamClientInterceptor
StreamClientLimitingInterceptor returns a new stream server interceptor that performs rate limiting on the request.
func StreamServerCtxAugmentingInterceptor ¶
func StreamServerCtxAugmentingInterceptor(f ContextAugmenter) grpc.StreamServerInterceptor
StreamServerLimitingInterceptor returns a new stream server interceptor that augments connection context.
func StreamServerLimitingInterceptor ¶
func StreamServerLimitingInterceptor(limiter ServerLimiter) grpc.StreamServerInterceptor
StreamServerLimitingInterceptor returns a new stream server interceptor that performs limiting based on the given context
func UnaryClientCtxAugmentingInterceptor ¶
func UnaryClientCtxAugmentingInterceptor(f ContextAugmenter) grpc.UnaryClientInterceptor
UnaryClientCtxAugmentingInterceptor returns a new unary client interceptor that augments connection context.
func UnaryClientLimitingInterceptor ¶
func UnaryClientLimitingInterceptor(limiter ClientLimiter) grpc.UnaryClientInterceptor
UnaryClientLimitingInterceptor returns a new unary client interceptor that performs request rate limiting.
func UnaryServerCtxAugmentingInterceptor ¶
func UnaryServerCtxAugmentingInterceptor(f ContextAugmenter) grpc.UnaryServerInterceptor
UnaryServerLimitingInterceptor returns a new unary server interceptor that augments connection context.
func UnaryServerLimitingInterceptor ¶
func UnaryServerLimitingInterceptor(limiter ServerLimiter) grpc.UnaryServerInterceptor
UnaryServerLimitingInterceptor returns a new unary server interceptor that performs limiting based on the given context
Types ¶
type ClientLimiter ¶
type ClientLimiter interface { // Wait blocks until limiter permits an event to happen. // It returns an error if the Context is // canceled, or the expected wait time exceeds the Context's Deadline. Wait(context.Context) error }
ClientLimiter defines the interface to perform client-side request rate limiting. You can use golang.org/x/time/rate.Limiter as an implementation of this interface.
type ContextAugmenter ¶
func JoinContexts ¶
func JoinContexts(aux context.Context) ContextAugmenter
JoinContexts returns a ContextAugmenter that alters the main context to propagate cancellation from the aux context. The returned context uses main as the parent context to inherit attached values.
This helper is used here to propagate done signal from both gRPC stream's context (stream is closed/broken) and main program's context (program needs to stop). Polling should stop when one of this conditions happens so using only one of these two contexts is not good enough.
type ServerLimiter ¶
type ServerLimiter interface { // Allow should return true and consume one "limitable event" if the limit has not been exceeded. Otherwise, it returns false and does not count towards the limit Allow(ctx context.Context) bool }
ServerLimiter defines the interface to perform server-side request rate limiting. Inspired by golang.org/x/time/rate.Limiter, but accepts a context