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:44:30 +0300
commit04d42dd6e30f0a1638445df9a3f2eb85e75171ee (patch)
tree294da5371c48341e0eeaad02a729d87b03d981d7
parentc0fae08db4a3d19a86d899ae94296e022ab0ac26 (diff)
service: Simplify injection of dependencies for Namespace 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/namespace/server.go5
-rw-r--r--internal/gitaly/service/namespace/testhelper_test.go2
-rw-r--r--internal/gitaly/service/setup/register.go2
3 files changed, 5 insertions, 4 deletions
diff --git a/internal/gitaly/service/namespace/server.go b/internal/gitaly/service/namespace/server.go
index b0c31d6e6..1c2a2df68 100644
--- a/internal/gitaly/service/namespace/server.go
+++ b/internal/gitaly/service/namespace/server.go
@@ -1,6 +1,7 @@
package namespace
import (
+ "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"
)
@@ -11,6 +12,6 @@ type server struct {
}
// NewServer creates a new instance of a gRPC namespace server
-func NewServer(locator storage.Locator) gitalypb.NamespaceServiceServer {
- return &server{locator: locator}
+func NewServer(deps *service.Dependencies) gitalypb.NamespaceServiceServer {
+ return &server{locator: deps.GetLocator()}
}
diff --git a/internal/gitaly/service/namespace/testhelper_test.go b/internal/gitaly/service/namespace/testhelper_test.go
index 2d8bd9bb4..79b1a5a8d 100644
--- a/internal/gitaly/service/namespace/testhelper_test.go
+++ b/internal/gitaly/service/namespace/testhelper_test.go
@@ -23,7 +23,7 @@ func setupNamespaceService(tb testing.TB, opts ...testserver.GitalyServerOpt) (c
cfg := cfgBuilder.Build(tb)
addr := testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterNamespaceServiceServer(srv, NewServer(deps.GetLocator()))
+ gitalypb.RegisterNamespaceServiceServer(srv, NewServer(deps))
}, opts...)
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go
index c53843498..f2830e113 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -56,7 +56,7 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterCleanupServiceServer(srv, cleanup.NewServer(deps))
gitalypb.RegisterCommitServiceServer(srv, commit.NewServer(deps))
gitalypb.RegisterDiffServiceServer(srv, diff.NewServer(deps))
- gitalypb.RegisterNamespaceServiceServer(srv, namespace.NewServer(deps.GetLocator()))
+ gitalypb.RegisterNamespaceServiceServer(srv, namespace.NewServer(deps))
gitalypb.RegisterOperationServiceServer(srv, operations.NewServer(
deps.GetHookManager(),
deps.GetTxManager(),