ratelimit

package module
v0.0.0-...-98190a3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 6 Imported by: 2

README

rate-limiter-grpc-go

grpc-go interceptor that can limit grpc requests both client and server. Limiter allow requests only if the number of requests per second is less than the specified number.

Usage

  • client
// allow two requests per seconds
conn, err := grpc.Dial(address,grpc.WithUnaryInterceptor(ratelimit.UnaryClientInterceptor(ratelimit.NewLimiter(2))))
...
client := pb.NewService(conn)
  • server
receive request at 1586597159
receive request at 1586597159
receive request at 1586597160
receive request at 1586597160
receive request at 1586597161
receive request at 1586597161
receive request at 1586597162
receive request at 1586597162
receive request at 1586597163
receive request at 1586597163

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter

func NewLimiter(count int) grpc_ratelimit.Limiter

NewLimiter return new go-grpc Limiter, specified the number of requests you want to limit as a counts per second.

func StreamClientInterceptor

func StreamClientInterceptor(limiter grpc_ratelimit.Limiter) grpc.StreamClientInterceptor

StreamServerInterceptor return stream server unary interceptor that limit requests.

func StreamServerInterceptor

func StreamServerInterceptor(limiter grpc_ratelimit.Limiter) grpc.StreamServerInterceptor

StreamServerInterceptor return stream server unary interceptor that limit requests.

func UnaryClientInterceptor

func UnaryClientInterceptor(limiter grpc_ratelimit.Limiter) grpc.UnaryClientInterceptor

UnaryServerInterceptor return server unary interceptor that limit requests.

func UnaryServerInterceptor

func UnaryServerInterceptor(limiter grpc_ratelimit.Limiter) grpc.UnaryServerInterceptor

UnaryServerInterceptor return server unary interceptor that limit requests.

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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