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>2021-04-08 08:58:30 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-09 13:48:00 +0300
commit08a887f5371c46598cd49fe653757cbd5d6f0abf (patch)
tree7776ca57e613fa46be0dba4dfed2e02038ec5a09
parent3ac2b729a072beb0ec09d3a05fa673ea24105be8 (diff)
ref: Inject transaction manager
We're about to introduce manual voting on transactions into the ref service. As a preparatory step, this commit injects the transaction manager into the server.
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go2
-rw-r--r--internal/gitaly/service/ref/server.go11
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go2
-rw-r--r--internal/gitaly/service/register.go2
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote_test.go5
-rw-r--r--internal/middleware/commandstatshandler/commandstatshandler_test.go4
-rw-r--r--internal/praefect/replicator_test.go2
7 files changed, 20 insertions, 8 deletions
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 7803f5a9d..47030d29a 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -90,7 +90,7 @@ func runOperationServiceServer(t *testing.T) (string, func()) {
gitalypb.RegisterOperationServiceServer(srv.GrpcServer(), server)
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hook.NewServer(config.Config, hookManager, gitCmdFactory))
gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(config.Config, RubyServer, locator, txManager, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory))
+ gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory, txManager))
gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), commit.NewServer(config.Config, locator, gitCmdFactory, nil))
gitalypb.RegisterSSHServiceServer(srv.GrpcServer(), ssh.NewServer(config.Config, locator, gitCmdFactory))
reflection.Register(srv.GrpcServer())
diff --git a/internal/gitaly/service/ref/server.go b/internal/gitaly/service/ref/server.go
index 610e98e0f..7c0da1771 100644
--- a/internal/gitaly/service/ref/server.go
+++ b/internal/gitaly/service/ref/server.go
@@ -3,17 +3,24 @@ package ref
import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
type server struct {
cfg config.Cfg
+ txManager transaction.Manager
locator storage.Locator
gitCmdFactory git.CommandFactory
}
// NewServer creates a new instance of a grpc RefServer
-func NewServer(cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.RefServiceServer {
- return &server{cfg: cfg, locator: locator, gitCmdFactory: gitCmdFactory}
+func NewServer(cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory, txManager transaction.Manager) gitalypb.RefServiceServer {
+ return &server{
+ cfg: cfg,
+ txManager: txManager,
+ locator: locator,
+ gitCmdFactory: gitCmdFactory,
+ }
}
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index 1b9597b18..81ed79fdb 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -77,7 +77,7 @@ func runRefServiceServer(t testing.TB, cfg config.Cfg) string {
gitCmdFactory := git.NewExecCommandFactory(cfg)
srv := testhelper.NewServer(t, nil, nil, testhelper.WithInternalSocket(cfg))
- gitalypb.RegisterRefServiceServer(srv.GrpcServer(), NewServer(cfg, locator, gitCmdFactory))
+ gitalypb.RegisterRefServiceServer(srv.GrpcServer(), NewServer(cfg, locator, gitCmdFactory, txManager))
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hookservice.NewServer(cfg, hookManager, gitCmdFactory))
srv.Start(t)
t.Cleanup(srv.Stop)
diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go
index 7b9934bf2..9941c5887 100644
--- a/internal/gitaly/service/register.go
+++ b/internal/gitaly/service/register.go
@@ -77,7 +77,7 @@ func RegisterAll(
gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(cfg, locator, gitCmdFactory))
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer(locator))
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator, conns, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator, gitCmdFactory))
+ gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator, gitCmdFactory, txManager))
gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, txManager, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer(
cfg,
diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go
index b34dda6e8..5f537dcee 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote_test.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
@@ -15,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ref"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/remote"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ssh"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/storage"
@@ -71,13 +73,14 @@ func testSuccessfulFetchInternalRemote(t *testing.T, ctx context.Context) {
locator := config.NewLocator(config.Config)
gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ txManager := transaction.NewManager(config.Config, backchannel.NewRegistry())
hookManager := &mockHookManager{}
gitaly0Server := testhelper.NewServer(t, nil, nil,
testhelper.WithStorages([]string{"gitaly-0"}),
testhelper.WithInternalSocket(config.Config),
)
gitalypb.RegisterSSHServiceServer(gitaly0Server.GrpcServer(), ssh.NewServer(config.Config, locator, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(gitaly0Server.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory))
+ gitalypb.RegisterRefServiceServer(gitaly0Server.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory, txManager))
gitalypb.RegisterHookServiceServer(gitaly0Server.GrpcServer(), hook.NewServer(config.Config, hookManager, gitCmdFactory))
reflection.Register(gitaly0Server.GrpcServer())
gitaly0Server.Start(t)
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go
index 177b02a45..740929ba9 100644
--- a/internal/middleware/commandstatshandler/commandstatshandler_test.go
+++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go
@@ -11,9 +11,11 @@ import (
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ref"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/log"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -44,7 +46,7 @@ func createNewServer(t *testing.T, cfg config.Cfg) *grpc.Server {
server := grpc.NewServer(opts...)
- gitalypb.RegisterRefServiceServer(server, ref.NewServer(cfg, config.NewLocator(cfg), git.NewExecCommandFactory(cfg)))
+ gitalypb.RegisterRefServiceServer(server, ref.NewServer(cfg, config.NewLocator(cfg), git.NewExecCommandFactory(cfg), transaction.NewManager(cfg, backchannel.NewRegistry())))
return server
}
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index e18cc5eda..e8792a6bc 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -1065,7 +1065,7 @@ func newReplicationService(tb testing.TB) (*grpc.Server, string) {
gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer(gitaly_config.Config, locator, gitCmdFactory))
gitalypb.RegisterRemoteServiceServer(svr, remote.NewServer(gitaly_config.Config, RubyServer, locator, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(svr, ssh.NewServer(gitaly_config.Config, locator, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(svr, ref.NewServer(gitaly_config.Config, locator, gitCmdFactory))
+ gitalypb.RegisterRefServiceServer(svr, ref.NewServer(gitaly_config.Config, locator, gitCmdFactory, txManager))
gitalypb.RegisterHookServiceServer(svr, hook.NewServer(gitaly_config.Config, hookManager, gitCmdFactory))
healthpb.RegisterHealthServer(svr, health.NewServer())
reflection.Register(svr)