diff options
Diffstat (limited to 'internal/gitaly/service/ssh/server.go')
-rw-r--r-- | internal/gitaly/service/ssh/server.go | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/internal/gitaly/service/ssh/server.go b/internal/gitaly/service/ssh/server.go index 12bc965cd..95188c11e 100644 --- a/internal/gitaly/service/ssh/server.go +++ b/internal/gitaly/service/ssh/server.go @@ -7,6 +7,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/git" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/transaction" + "gitlab.com/gitlab-org/gitaly/v15/internal/helper" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" ) @@ -17,12 +18,12 @@ var ( type server struct { gitalypb.UnimplementedSSHServiceServer - locator storage.Locator - gitCmdFactory git.CommandFactory - txManager transaction.Manager - uploadPackRequestTimeout time.Duration - uploadArchiveRequestTimeout time.Duration - packfileNegotiationMetrics *prometheus.CounterVec + locator storage.Locator + gitCmdFactory git.CommandFactory + txManager transaction.Manager + uploadPackRequestTimeoutTickerFactory func() helper.Ticker + uploadArchiveRequestTimeoutTickerFactory func() helper.Ticker + packfileNegotiationMetrics *prometheus.CounterVec } // NewServer creates a new instance of a grpc SSHServer @@ -33,11 +34,15 @@ func NewServer( serverOpts ...ServerOpt, ) gitalypb.SSHServiceServer { s := &server{ - locator: locator, - gitCmdFactory: gitCmdFactory, - txManager: txManager, - uploadPackRequestTimeout: defaultUploadPackRequestTimeout, - uploadArchiveRequestTimeout: defaultUploadArchiveRequestTimeout, + locator: locator, + gitCmdFactory: gitCmdFactory, + txManager: txManager, + uploadPackRequestTimeoutTickerFactory: func() helper.Ticker { + return helper.NewTimerTicker(defaultUploadPackRequestTimeout) + }, + uploadArchiveRequestTimeoutTickerFactory: func() helper.Ticker { + return helper.NewTimerTicker(defaultUploadArchiveRequestTimeout) + }, packfileNegotiationMetrics: prometheus.NewCounterVec( prometheus.CounterOpts{}, []string{"git_negotiation_feature"}, @@ -54,17 +59,17 @@ func NewServer( // ServerOpt is a self referential option for server type ServerOpt func(s *server) -// WithUploadPackRequestTimeout sets the upload pack request timeout -func WithUploadPackRequestTimeout(d time.Duration) ServerOpt { +// WithUploadPackRequestTimeoutTickerFactory sets the upload pack request timeout ticker factory. +func WithUploadPackRequestTimeoutTickerFactory(factory func() helper.Ticker) ServerOpt { return func(s *server) { - s.uploadPackRequestTimeout = d + s.uploadPackRequestTimeoutTickerFactory = factory } } -// WithArchiveRequestTimeout sets the upload pack request timeout -func WithArchiveRequestTimeout(d time.Duration) ServerOpt { +// WithArchiveRequestTimeoutTickerFactory sets the upload pack request timeout ticker factory. +func WithArchiveRequestTimeoutTickerFactory(factory func() helper.Ticker) ServerOpt { return func(s *server) { - s.uploadArchiveRequestTimeout = d + s.uploadArchiveRequestTimeoutTickerFactory = factory } } |