Codebase list golang-github-go-kit-kit / 43c4183
Downstream usages of ratelimit package Nelz 6 years ago
5 changed file(s) with 16 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "context"
4 "time"
45
5 rl "github.com/juju/ratelimit"
6 "golang.org/x/time/rate"
7
68 stdopentracing "github.com/opentracing/opentracing-go"
79 "github.com/sony/gobreaker"
810
3032 var sumEndpoint endpoint.Endpoint
3133 {
3234 sumEndpoint = MakeSumEndpoint(svc)
33 sumEndpoint = ratelimit.NewTokenBucketLimiter(rl.NewBucketWithRate(1, 1))(sumEndpoint)
35 sumEndpoint = ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 1))(sumEndpoint)
3436 sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(sumEndpoint)
3537 sumEndpoint = opentracing.TraceServer(trace, "Sum")(sumEndpoint)
3638 sumEndpoint = LoggingMiddleware(log.With(logger, "method", "Sum"))(sumEndpoint)
3941 var concatEndpoint endpoint.Endpoint
4042 {
4143 concatEndpoint = MakeConcatEndpoint(svc)
42 concatEndpoint = ratelimit.NewTokenBucketLimiter(rl.NewBucketWithRate(100, 100))(concatEndpoint)
44 concatEndpoint = ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 100))(concatEndpoint)
4345 concatEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(concatEndpoint)
4446 concatEndpoint = opentracing.TraceServer(trace, "Concat")(concatEndpoint)
4547 concatEndpoint = LoggingMiddleware(log.With(logger, "method", "Concat"))(concatEndpoint)
66
77 "google.golang.org/grpc"
88
9 jujuratelimit "github.com/juju/ratelimit"
109 stdopentracing "github.com/opentracing/opentracing-go"
1110 "github.com/sony/gobreaker"
1211 oldcontext "golang.org/x/net/context"
12 "golang.org/x/time/rate"
1313
1414 "github.com/go-kit/kit/circuitbreaker"
1515 "github.com/go-kit/kit/endpoint"
7575 // construct per-endpoint circuitbreaker middlewares to demonstrate how
7676 // that's done, although they could easily be combined into a single breaker
7777 // for the entire remote instance, too.
78 limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
78 limiter := ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 100))
7979
8080 // Each individual endpoint is an http/transport.Client (which implements
8181 // endpoint.Endpoint) that gets wrapped with various middlewares. If you
1010 "strings"
1111 "time"
1212
13 jujuratelimit "github.com/juju/ratelimit"
13 "golang.org/x/time/rate"
14
1415 stdopentracing "github.com/opentracing/opentracing-go"
1516 "github.com/sony/gobreaker"
1617
6768 // construct per-endpoint circuitbreaker middlewares to demonstrate how
6869 // that's done, although they could easily be combined into a single breaker
6970 // for the entire remote instance, too.
70 limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
71 limiter := ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 100))
7172
7273 // Each individual endpoint is an http/transport.Client (which implements
7374 // endpoint.Endpoint) that gets wrapped with various middlewares. If you
33 "context"
44 "time"
55
6 jujuratelimit "github.com/juju/ratelimit"
6 "golang.org/x/time/rate"
7
78 "github.com/sony/gobreaker"
89
910 "github.com/go-kit/kit/circuitbreaker"
5758 // construct per-endpoint circuitbreaker middlewares to demonstrate how
5859 // that's done, although they could easily be combined into a single breaker
5960 // for the entire remote instance, too.
60 limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
61 limiter := ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 100))
6162
6263 // Each individual endpoint is an http/transport.Client (which implements
6364 // endpoint.Endpoint) that gets wrapped with various middlewares. If you
77 "strings"
88 "time"
99
10 jujuratelimit "github.com/juju/ratelimit"
10 "golang.org/x/time/rate"
11
1112 "github.com/sony/gobreaker"
1213
1314 "github.com/go-kit/kit/circuitbreaker"
4647 var e endpoint.Endpoint
4748 e = makeUppercaseProxy(ctx, instance)
4849 e = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(e)
49 e = ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(float64(qps), int64(qps)))(e)
50 e = ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), qps))(e)
5051 endpointer = append(endpointer, e)
5152 }
5253