-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
72 lines (64 loc) · 2.27 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package operations
import (
"context"
"gitlab.com/gitlab-org/gitaly/v15/client"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/quarantine"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v15/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook"
"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"
)
//nolint:stylecheck // This is unintentionally missing documentation.
type Server struct {
gitalypb.UnimplementedOperationServiceServer
hookManager hook.Manager
txManager transaction.Manager
locator storage.Locator
conns *client.Pool
git2goExecutor *git2go.Executor
gitCmdFactory git.CommandFactory
catfileCache catfile.Cache
updater *updateref.UpdaterWithHooks
}
// NewServer creates a new instance of a grpc OperationServiceServer
func NewServer(
hookManager hook.Manager,
txManager transaction.Manager,
locator storage.Locator,
conns *client.Pool,
git2goExecutor *git2go.Executor,
gitCmdFactory git.CommandFactory,
catfileCache catfile.Cache,
updater *updateref.UpdaterWithHooks,
) *Server {
return &Server{
hookManager: hookManager,
txManager: txManager,
locator: locator,
conns: conns,
git2goExecutor: git2goExecutor,
gitCmdFactory: gitCmdFactory,
catfileCache: catfileCache,
updater: updater,
}
}
func (s *Server) localrepo(repo repository.GitRepo) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
func (s *Server) quarantinedRepo(
ctx context.Context, repo *gitalypb.Repository,
) (*quarantine.Dir, *localrepo.Repo, error) {
quarantineDir, err := quarantine.New(ctx, repo, s.locator)
if err != nil {
return nil, nil, helper.ErrInternalf("creating object quarantine: %w", err)
}
quarantineRepo := s.localrepo(quarantineDir.QuarantinedRepo())
return quarantineDir, quarantineRepo, nil
}