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:
authorJohn Cai <jcai@gitlab.com>2022-04-21 18:52:27 +0300
committerJohn Cai <jcai@gitlab.com>2022-04-25 17:41:21 +0300
commit2ab11a368399340c57c6d66d5f6778d7af2eb967 (patch)
tree718604ff1a386cdba14f8f5b3d24f3010b1f0d64
parent953a7b80beb340565b30dce713747120552c23e5 (diff)
smarthttp: Add TransactionManager
This is a preperatory commit so that PostReceivePack can do transaction voting in the RPC handler. This adds a transaction manager to the server struct to be used by PostReceivePack.
-rw-r--r--internal/gitaly/service/setup/register.go1
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go1
-rw-r--r--internal/gitaly/service/smarthttp/server.go11
-rw-r--r--internal/gitaly/service/smarthttp/testhelper_test.go1
4 files changed, 12 insertions, 2 deletions
diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go
index 2cc0bcd9f..32746ce4a 100644
--- a/internal/gitaly/service/setup/register.go
+++ b/internal/gitaly/service/setup/register.go
@@ -111,6 +111,7 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterSmartHTTPServiceServer(srv, smarthttp.NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
+ deps.GetTxManager(),
deps.GetDiskCache(),
smarthttp.WithPackfileNegotiationMetrics(smarthttpPackfileNegotiationMetrics),
))
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 7eb070b4d..608cfd57f 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -761,6 +761,7 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
gitalypb.RegisterSmartHTTPServiceServer(srv, NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
+ deps.GetTxManager(),
deps.GetDiskCache(),
))
gitalypb.RegisterHookServiceServer(srv, hook.NewServer(deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache()))
diff --git a/internal/gitaly/service/smarthttp/server.go b/internal/gitaly/service/smarthttp/server.go
index e1a3c60d0..0145d54d9 100644
--- a/internal/gitaly/service/smarthttp/server.go
+++ b/internal/gitaly/service/smarthttp/server.go
@@ -5,6 +5,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/cache"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
)
@@ -14,15 +15,21 @@ type server struct {
gitCmdFactory git.CommandFactory
packfileNegotiationMetrics *prometheus.CounterVec
infoRefCache infoRefCache
+ txManager transaction.Manager
}
// NewServer creates a new instance of a grpc SmartHTTPServer
-func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory,
- cache cache.Streamer, serverOpts ...ServerOpt,
+func NewServer(
+ locator storage.Locator,
+ gitCmdFactory git.CommandFactory,
+ txManager transaction.Manager,
+ cache cache.Streamer,
+ serverOpts ...ServerOpt,
) gitalypb.SmartHTTPServiceServer {
s := &server{
locator: locator,
gitCmdFactory: gitCmdFactory,
+ txManager: txManager,
packfileNegotiationMetrics: prometheus.NewCounterVec(
prometheus.CounterOpts{},
[]string{"git_negotiation_feature"},
diff --git a/internal/gitaly/service/smarthttp/testhelper_test.go b/internal/gitaly/service/smarthttp/testhelper_test.go
index 68daaca57..321cfed87 100644
--- a/internal/gitaly/service/smarthttp/testhelper_test.go
+++ b/internal/gitaly/service/smarthttp/testhelper_test.go
@@ -31,6 +31,7 @@ func startSmartHTTPServerWithOptions(t *testing.T, cfg config.Cfg, opts []Server
gitalypb.RegisterSmartHTTPServiceServer(srv, NewServer(
deps.GetLocator(),
deps.GetGitCmdFactory(),
+ deps.GetTxManager(),
deps.GetDiskCache(),
opts...,
))