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:42:55 +0300
commitc0fae08db4a3d19a86d899ae94296e022ab0ac26 (patch)
tree667330537b85ebff006afa9341f8e7f75c18fba5
parentd8711fed302af9802e69d543b7e5a57bbaeeac3a (diff)
service: Simplify injection of dependencies for Diff 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/gitaly/service/diff/server.go9
-rw-r--r--internal/gitaly/service/diff/testhelper_test.go6
-rw-r--r--internal/gitaly/service/setup/register.go6
3 files changed, 7 insertions, 14 deletions
diff --git a/internal/gitaly/service/diff/server.go b/internal/gitaly/service/diff/server.go
index c54640cf2..156da0f56 100644
--- a/internal/gitaly/service/diff/server.go
+++ b/internal/gitaly/service/diff/server.go
@@ -4,6 +4,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"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/service"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -19,12 +20,12 @@ type server struct {
}
// NewServer creates a new instance of a gRPC DiffServer
-func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache catfile.Cache) gitalypb.DiffServiceServer {
+func NewServer(deps *service.Dependencies) gitalypb.DiffServiceServer {
return &server{
MsgSizeThreshold: msgSizeThreshold,
- locator: locator,
- gitCmdFactory: gitCmdFactory,
- catfileCache: catfileCache,
+ locator: deps.GetLocator(),
+ gitCmdFactory: deps.GetGitCmdFactory(),
+ catfileCache: deps.GetCatfileCache(),
}
}
diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go
index 4bde0b629..dba31eed6 100644
--- a/internal/gitaly/service/diff/testhelper_test.go
+++ b/internal/gitaly/service/diff/testhelper_test.go
@@ -23,11 +23,7 @@ func setupDiffService(tb testing.TB, opt ...testserver.GitalyServerOpt) (config.
cfg := testcfg.Build(tb)
addr := testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterDiffServiceServer(srv, NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterDiffServiceServer(srv, NewServer(deps))
gitalypb.RegisterRepositoryServiceServer(srv, repository.NewServer(
cfg,
deps.GetLocator(),
diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go
index f19f3aa5b..c53843498 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -55,11 +55,7 @@ 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))
- gitalypb.RegisterDiffServiceServer(srv, diff.NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterDiffServiceServer(srv, diff.NewServer(deps))
gitalypb.RegisterNamespaceServiceServer(srv, namespace.NewServer(deps.GetLocator()))
gitalypb.RegisterOperationServiceServer(srv, operations.NewServer(
deps.GetHookManager(),