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:
authorSami Hiltunen <shiltunen@gitlab.com>2023-06-30 14:29:10 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2023-10-18 00:20:42 +0300
commit0dc4822047a55270d41782467ce9b11fc7e43699 (patch)
treed1d259889b74d03cf335fd348431bfec39dd1d72 /internal/testhelper/testserver/gitaly.go
parenta91155af93c4f0376370f3f8e83ac06d6d5d37e4 (diff)
Wire TransactionMiddleware to GitalyServerFactory
We'll soon have middleware to handle transaction management for RPC in a general manner. This commit wires GitalyServerFactory to optionally configure a middleware for doing so in the right location.
Diffstat (limited to 'internal/testhelper/testserver/gitaly.go')
-rw-r--r--internal/testhelper/testserver/gitaly.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 1c7b48bd3..0302947e4 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -179,6 +179,7 @@ func runGitaly(tb testing.TB, cfg config.Cfg, registrar func(srv *grpc.Server, d
deps.GetBackchannelRegistry(),
deps.GetDiskCache(),
[]*limithandler.LimiterMiddleware{deps.GetLimitHandler()},
+ server.TransactionMiddleware{},
)
if cfg.RuntimeDir != "" {
@@ -270,6 +271,7 @@ type gitalyServerDeps struct {
backupSink backup.Sink
backupLocator backup.Locator
signingKey string
+ transactionRegistry *storagemgr.TransactionRegistry
}
func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg) *service.Dependencies {
@@ -303,9 +305,8 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg) *
gsd.gitCmdFactory = gittest.NewCommandFactory(tb, cfg)
}
- transactionRegistry := storagemgr.NewTransactionRegistry()
if gsd.hookMgr == nil {
- gsd.hookMgr = hook.NewManager(cfg, gsd.locator, gsd.logger, gsd.gitCmdFactory, gsd.txMgr, gsd.gitlabClient, hook.NewTransactionRegistry(transactionRegistry))
+ gsd.hookMgr = hook.NewManager(cfg, gsd.locator, gsd.logger, gsd.gitCmdFactory, gsd.txMgr, gsd.gitlabClient, hook.NewTransactionRegistry(gsd.transactionRegistry))
}
if gsd.catfileCache == nil {
@@ -385,7 +386,7 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg) *
RepositoryCounter: gsd.repositoryCounter,
UpdaterWithHooks: gsd.updaterWithHooks,
HousekeepingManager: gsd.housekeepingManager,
- TransactionRegistry: transactionRegistry,
+ TransactionRegistry: gsd.transactionRegistry,
PartitionManager: partitionManager,
BackupSink: gsd.backupSink,
BackupLocator: gsd.backupLocator,
@@ -518,3 +519,11 @@ func WithSigningKey(signingKey string) GitalyServerOpt {
return deps
}
}
+
+// WithTransactionRegistry sets the transaction registry that will be used for Gitaly services.
+func WithTransactionRegistry(registry *storagemgr.TransactionRegistry) GitalyServerOpt {
+ return func(deps gitalyServerDeps) gitalyServerDeps {
+ deps.transactionRegistry = registry
+ return deps
+ }
+}