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:
authorJames Fargher <jfargher@gitlab.com>2023-05-04 06:14:36 +0300
committerJames Fargher <jfargher@gitlab.com>2023-05-11 00:18:08 +0300
commit5b98c911001eca38dbb98610127f88f8423dd401 (patch)
tree05b3e8ae29fab046b694421bd2e157a0c7a7ca30 /internal
parentb43b88fda61b358e6083e2c5b2112e399325d6fa (diff)
internalgitaly: Add service dependencies needed to take backups
Soon we will be adding an RPC to take repository backups. So here we hook up these dependencies in preparation.
Diffstat (limited to 'internal')
-rw-r--r--internal/gitaly/service/internalgitaly/server.go22
-rw-r--r--internal/gitaly/service/internalgitaly/walkrepos_test.go11
-rw-r--r--internal/gitaly/service/setup/register.go7
3 files changed, 35 insertions, 5 deletions
diff --git a/internal/gitaly/service/internalgitaly/server.go b/internal/gitaly/service/internalgitaly/server.go
index b24ea4ede..d0ce88352 100644
--- a/internal/gitaly/service/internalgitaly/server.go
+++ b/internal/gitaly/service/internalgitaly/server.go
@@ -1,16 +1,32 @@
package internalgitaly
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/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
type server struct {
gitalypb.UnimplementedInternalGitalyServer
- storages []config.Storage
+ storages []config.Storage
+ locator storage.Locator
+ gitCmdFactory git.CommandFactory
+ catfileCache catfile.Cache
}
// NewServer return an instance of the Gitaly service.
-func NewServer(storages []config.Storage) gitalypb.InternalGitalyServer {
- return &server{storages: storages}
+func NewServer(
+ storages []config.Storage,
+ locator storage.Locator,
+ gitCmdFactory git.CommandFactory,
+ catfileCache catfile.Cache,
+) gitalypb.InternalGitalyServer {
+ return &server{
+ storages: storages,
+ locator: locator,
+ gitCmdFactory: gitCmdFactory,
+ catfileCache: catfileCache,
+ }
}
diff --git a/internal/gitaly/service/internalgitaly/walkrepos_test.go b/internal/gitaly/service/internalgitaly/walkrepos_test.go
index b69a8cf70..de4e5b23d 100644
--- a/internal/gitaly/service/internalgitaly/walkrepos_test.go
+++ b/internal/gitaly/service/internalgitaly/walkrepos_test.go
@@ -9,6 +9,7 @@ import (
"time"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
@@ -70,12 +71,20 @@ func TestWalkRepos(t *testing.T) {
os.Chtimes(testRepo2Path, time.Now(), modifiedDate),
)
+ catfileCache := catfile.NewCache(cfg)
+ t.Cleanup(catfileCache.Stop)
+
// to test a directory being deleted during a walk, we must delete a directory after
// the file walk has started. To achieve that, we wrap the server to pass down a wrapped
// stream that allows us to hook in to stream responses. We then delete 'b' when
// the first repo 'a' is being streamed to the client.
deleteOnce := sync.Once{}
- srv := NewServer([]config.Storage{{Name: storageName, Path: storageRoot}})
+ srv := NewServer(
+ []config.Storage{{Name: storageName, Path: storageRoot}},
+ config.NewLocator(cfg),
+ gittest.NewCommandFactory(t, cfg),
+ catfileCache,
+ )
wsrv := &serverWrapper{
srv,
func(r *gitalypb.WalkReposRequest, s gitalypb.InternalGitaly_WalkReposServer) error {
diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go
index 2c40bb220..50f0482c1 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -144,7 +144,12 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) {
deps.GetPackObjectsConcurrencyTracker(),
deps.GetPackObjectsLimiter(),
))
- gitalypb.RegisterInternalGitalyServer(srv, internalgitaly.NewServer(deps.GetCfg().Storages))
+ gitalypb.RegisterInternalGitalyServer(srv, internalgitaly.NewServer(
+ deps.GetCfg().Storages,
+ deps.GetLocator(),
+ deps.GetGitCmdFactory(),
+ deps.GetCatfileCache(),
+ ))
healthpb.RegisterHealthServer(srv, health.NewServer())
reflection.Register(srv)