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
path: root/cmd
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-14 16:01:23 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-15 10:15:46 +0300
commitbe7617b20bbeb81c1036443c6b176574cc3d3b8f (patch)
tree8b02eb47a96ddd42269e8424ca2927fbe75936b5 /cmd
parentbbc8ddda6b33ee1afa88b328a5cf53ce7f5d64f0 (diff)
limithandler: Refactor package to not use global state
The limithandler package uses global variables to both track Prometheus metrics and to handle its configuration. Especially the latter is really fragile, where we need to set up state of the limithandler in various places by calling global functions. Fix this by making the `LimiterMiddleware` self-contained, where it hosts all configuration as well as the Prometheus metrics.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitaly-ssh/auth_test.go2
-rw-r--r--cmd/gitaly/main.go3
2 files changed, 3 insertions, 2 deletions
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go
index c15901765..3dd82bea1 100644
--- a/cmd/gitaly-ssh/auth_test.go
+++ b/cmd/gitaly-ssh/auth_test.go
@@ -155,7 +155,7 @@ func runServer(t *testing.T, secure bool, cfg config.Cfg, connectionType string,
t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive,
), cfg)
gitCmdFactory := git.NewExecCommandFactory(cfg)
- limitHandler := limithandler.New(limithandler.LimitConcurrencyByRepo)
+ limitHandler := limithandler.New(cfg, limithandler.LimitConcurrencyByRepo)
diskCache := cache.New(cfg, locator)
srv, err := server.New(secure, cfg, testhelper.NewDiscardingLogEntry(t), registry, diskCache, limitHandler)
require.NoError(t, err)
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go
index 2699fa5de..8b0e0da6e 100644
--- a/cmd/gitaly/main.go
+++ b/cmd/gitaly/main.go
@@ -192,7 +192,8 @@ func run(cfg config.Cfg) error {
return fmt.Errorf("disk cache walkers: %w", err)
}
- limitHandler := limithandler.New(limithandler.LimitConcurrencyByRepo)
+ limitHandler := limithandler.New(cfg, limithandler.LimitConcurrencyByRepo)
+ prometheus.MustRegister(limitHandler)
gitalyServerFactory := server.NewGitalyServerFactory(cfg, glog.Default(), registry, diskCache, limitHandler)
defer gitalyServerFactory.Stop()