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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-18 11:36:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-19 09:41:32 +0300
commitd8711fed302af9802e69d543b7e5a57bbaeeac3a (patch)
tree8902c7a42083b5535d6eec21fa0c5322fcddf621
parent409e5de8169f0c306c2e113a054450bc9fa66612 (diff)
service: Simplify injection of dependencies for Commit server
While we already have a `service.Dependencies` type around for quite a long time, we still pass in dependencies explicitly when constructing the actual server. This makes it harder than necessary to make a server require more dependencies as you will have to adjust all callsites where the server is currently getting constructed. Simplify the code to instead inject the `service.Dependencies` type into the server directly. This will allow us to propagate dependencies more readily in the future.
-rw-r--r--internal/git/remoterepo/testhelper_test.go7
-rw-r--r--internal/gitaly/service/commit/server.go16
-rw-r--r--internal/gitaly/service/commit/testhelper_test.go7
-rw-r--r--internal/gitaly/service/conflicts/testhelper_test.go7
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go7
-rw-r--r--internal/gitaly/service/repository/testhelper_test.go7
-rw-r--r--internal/gitaly/service/setup/register.go7
7 files changed, 12 insertions, 46 deletions
diff --git a/internal/git/remoterepo/testhelper_test.go b/internal/git/remoterepo/testhelper_test.go
index 2a9b0ce9b..1b7b24871 100644
--- a/internal/git/remoterepo/testhelper_test.go
+++ b/internal/git/remoterepo/testhelper_test.go
@@ -35,12 +35,7 @@ func setupGitalyServer(t *testing.T) config.Cfg {
deps.GetBackupLocator(),
deps.GetRepositoryCounter(),
))
- gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
gitalypb.RegisterRefServiceServer(srv, ref.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
diff --git a/internal/gitaly/service/commit/server.go b/internal/gitaly/service/commit/server.go
index 4d1a70268..a2465f537 100644
--- a/internal/gitaly/service/commit/server.go
+++ b/internal/gitaly/service/commit/server.go
@@ -5,6 +5,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -18,17 +19,12 @@ type server struct {
}
// NewServer creates a new instance of a grpc CommitServiceServer
-func NewServer(
- cfg config.Cfg,
- locator storage.Locator,
- gitCmdFactory git.CommandFactory,
- catfileCache catfile.Cache,
-) gitalypb.CommitServiceServer {
+func NewServer(deps *service.Dependencies) gitalypb.CommitServiceServer {
return &server{
- locator: locator,
- gitCmdFactory: gitCmdFactory,
- catfileCache: catfileCache,
- cfg: cfg,
+ locator: deps.GetLocator(),
+ gitCmdFactory: deps.GetGitCmdFactory(),
+ catfileCache: deps.GetCatfileCache(),
+ cfg: deps.GetCfg(),
}
}
diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go
index 44356057a..a70a4c760 100644
--- a/internal/gitaly/service/commit/testhelper_test.go
+++ b/internal/gitaly/service/commit/testhelper_test.go
@@ -40,12 +40,7 @@ func setupCommitService(
func startTestServices(tb testing.TB, cfg config.Cfg, opts ...testserver.GitalyServerOpt) string {
tb.Helper()
return testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterCommitServiceServer(srv, NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, NewServer(deps))
gitalypb.RegisterRepositoryServiceServer(srv, repository.NewServer(
cfg,
deps.GetLocator(),
diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go
index 1d1b2f6e8..fe320022a 100644
--- a/internal/gitaly/service/conflicts/testhelper_test.go
+++ b/internal/gitaly/service/conflicts/testhelper_test.go
@@ -68,12 +68,7 @@ func runConflictsServer(tb testing.TB, cfg config.Cfg, hookManager hook.Manager)
deps.GetPackObjectsCache(),
deps.GetPackObjectsLimiter(),
))
- gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
}, testserver.WithHookManager(hookManager))
}
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 8d0a04074..ae44ec3ff 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -116,12 +116,7 @@ func runOperationServiceServer(tb testing.TB, cfg config.Cfg, options ...testser
deps.GetTxManager(),
deps.GetCatfileCache(),
))
- gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
gitalypb.RegisterSSHServiceServer(srv, ssh.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go
index ba57b32e7..635bcb8d1 100644
--- a/internal/gitaly/service/repository/testhelper_test.go
+++ b/internal/gitaly/service/repository/testhelper_test.go
@@ -93,12 +93,7 @@ func runRepositoryService(tb testing.TB, cfg config.Cfg, opts ...testserver.Gita
deps.GetTxManager(),
deps.GetCatfileCache(),
))
- gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
gitalypb.RegisterObjectPoolServiceServer(srv, objectpool.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go
index 89a7d439a..f19f3aa5b 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -54,12 +54,7 @@ var (
func RegisterAll(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterBlobServiceServer(srv, blob.NewServer(deps))
gitalypb.RegisterCleanupServiceServer(srv, cleanup.NewServer(deps))
- gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(
- deps.GetCfg(),
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
gitalypb.RegisterDiffServiceServer(srv, diff.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),