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:40:32 +0300
commitb6f77b16e3d78295e675ff674e83f62611780867 (patch)
treea81958216f08f1f5443bdbd59ec957072fb59686
parent0bef3b7e4677bb820c8ab8946024688f27fc5282 (diff)
service: Simplify injection of dependencies for Blob 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/blob/server.go9
-rw-r--r--internal/gitaly/service/blob/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/blob/server.go b/internal/gitaly/service/blob/server.go
index 8e31fdbb6..c76bbd917 100644
--- a/internal/gitaly/service/blob/server.go
+++ b/internal/gitaly/service/blob/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"
)
@@ -16,11 +17,11 @@ type server struct {
}
// NewServer creates a new instance of a grpc BlobServer
-func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache catfile.Cache) gitalypb.BlobServiceServer {
+func NewServer(deps *service.Dependencies) gitalypb.BlobServiceServer {
return &server{
- locator: locator,
- gitCmdFactory: gitCmdFactory,
- catfileCache: catfileCache,
+ locator: deps.GetLocator(),
+ gitCmdFactory: deps.GetGitCmdFactory(),
+ catfileCache: deps.GetCatfileCache(),
}
}
diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go
index 4ca1a85ae..f54f476c9 100644
--- a/internal/gitaly/service/blob/testhelper_test.go
+++ b/internal/gitaly/service/blob/testhelper_test.go
@@ -24,11 +24,7 @@ func setup(tb testing.TB, ctx context.Context) (config.Cfg, gitalypb.BlobService
cfg := testcfg.Build(tb)
addr := testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterBlobServiceServer(srv, NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterBlobServiceServer(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 b14298f1a..bc01f02ec 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -52,11 +52,7 @@ var (
// RegisterAll will register all the known gRPC services on the provided gRPC service instance.
func RegisterAll(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterBlobServiceServer(srv, blob.NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetCatfileCache(),
- ))
+ gitalypb.RegisterBlobServiceServer(srv, blob.NewServer(deps))
gitalypb.RegisterCleanupServiceServer(srv, cleanup.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),