diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2023-06-30 14:29:10 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2023-10-18 00:20:42 +0300 |
commit | 0dc4822047a55270d41782467ce9b11fc7e43699 (patch) | |
tree | d1d259889b74d03cf335fd348431bfec39dd1d72 /internal/testhelper/testserver/gitaly.go | |
parent | a91155af93c4f0376370f3f8e83ac06d6d5d37e4 (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.go | 15 |
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 + } +} |