Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2022-03-25 16:20:12 +0300
committerJohn Cai <jcai@gitlab.com>2022-04-06 22:27:35 +0300
commit57db9d3f3c2945dfbe3af16392b2568a0081240a (patch)
tree20a0db33bc5f0e5a812cff46f31cf83a3927a778
parentf4cb81c2dcdfaaa67a2752f7451917f6080db652 (diff)
Include rate limiter as a middleware in Gitaly
Add a rate limiting middleware into the interceptor chain for a Gitaly server. Changelog: added
-rw-r--r--cmd/gitaly/main.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go
index 818f5ce2f..6fcda7527 100644
--- a/cmd/gitaly/main.go
+++ b/cmd/gitaly/main.go
@@ -213,10 +213,26 @@ func run(cfg config.Cfg) error {
return fmt.Errorf("disk cache walkers: %w", err)
}
- limitHandler := limithandler.New(cfg, limithandler.LimitConcurrencyByRepo, limithandler.WithConcurrencyLimiters)
- prometheus.MustRegister(limitHandler)
+ concurrencyLimitHandler := limithandler.New(
+ cfg,
+ limithandler.LimitConcurrencyByRepo,
+ limithandler.WithConcurrencyLimiters,
+ )
- gitalyServerFactory := server.NewGitalyServerFactory(cfg, glog.Default(), registry, diskCache, []*limithandler.LimiterMiddleware{limitHandler})
+ rateLimitHandler := limithandler.New(
+ cfg,
+ limithandler.LimitConcurrencyByRepo,
+ limithandler.WithRateLimiters(ctx),
+ )
+ prometheus.MustRegister(concurrencyLimitHandler, rateLimitHandler)
+
+ gitalyServerFactory := server.NewGitalyServerFactory(
+ cfg,
+ glog.Default(),
+ registry,
+ diskCache,
+ []*limithandler.LimiterMiddleware{concurrencyLimitHandler, rateLimitHandler},
+ )
defer gitalyServerFactory.Stop()
ling, err := linguist.New(cfg, gitCmdFactory)