...
1 package ratelimit_test
2
3 import (
4 "github.com/grpc-ecosystem/go-grpc-middleware"
5 "github.com/grpc-ecosystem/go-grpc-middleware/ratelimit"
6 "google.golang.org/grpc"
7 )
8
9
10
11 type alwaysPassLimiter struct{}
12
13 func (*alwaysPassLimiter) Limit() bool {
14 return false
15 }
16
17
18 func Example() {
19
20
21 limiter := &alwaysPassLimiter{}
22 _ = grpc.NewServer(
23 grpc_middleware.WithUnaryServerChain(
24 ratelimit.UnaryServerInterceptor(limiter),
25 ),
26 grpc_middleware.WithStreamServerChain(
27 ratelimit.StreamServerInterceptor(limiter),
28 ),
29 )
30 }
31
View as plain text