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:
Diffstat (limited to 'internal/praefect/service/info/server.go')
-rw-r--r--internal/praefect/service/info/server.go57
1 files changed, 45 insertions, 12 deletions
diff --git a/internal/praefect/service/info/server.go b/internal/praefect/service/info/server.go
index 9cb67efa3..e54ea267a 100644
--- a/internal/praefect/service/info/server.go
+++ b/internal/praefect/service/info/server.go
@@ -7,27 +7,60 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/internal/praefect/nodes"
+ "gitlab.com/gitlab-org/gitaly/internal/praefect/service"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
+// AssignmentStore is an interface for getting repository host node assignments.
+//
+// This duplicates the praefect.AssignmentGetter type as it is not possible to import anything from
+// `praefect` to `info` packages due to cyclic dependencies.
+type AssignmentStore interface {
+ // GetHostAssignments returns the names of the storages assigned to host the repository.
+ // The primary node must always be assigned.
+ GetHostAssignments(ctx context.Context, virtualStorage, relativePath string) ([]string, error)
+ // SetReplicationFactor sets a repository's replication factor and returns the current assignments.
+ SetReplicationFactor(ctx context.Context, virtualStorage, relativePath string, replicationFactor int) ([]string, error)
+}
+
+// PrimaryGetter is an interface for getting a primary of a repository.
+//
+// This duplicates the praefect.PrimaryGetter type as it is not possible to import anything from
+// `praefect` to `info` packages due to cyclic dependencies.
+type PrimaryGetter interface {
+ // GetPrimary returns the primary storage for a given repository.
+ GetPrimary(ctx context.Context, virtualStorage string, relativePath string) (string, error)
+}
+
// Server is a InfoService server
type Server struct {
- nodeMgr nodes.Manager
- conf config.Config
- queue datastore.ReplicationEventQueue
- rs datastore.RepositoryStore
-
- rfs ReplicationFactorSetter
+ nodeMgr nodes.Manager
+ conf config.Config
+ queue datastore.ReplicationEventQueue
+ rs datastore.RepositoryStore
+ assignmentStore AssignmentStore
+ conns service.Connections
+ primaryGetter PrimaryGetter
}
// NewServer creates a new instance of a grpc InfoServiceServer
-func NewServer(nodeMgr nodes.Manager, conf config.Config, queue datastore.ReplicationEventQueue, rs datastore.RepositoryStore, rfs ReplicationFactorSetter) gitalypb.PraefectInfoServiceServer {
+func NewServer(
+ nodeMgr nodes.Manager,
+ conf config.Config,
+ queue datastore.ReplicationEventQueue,
+ rs datastore.RepositoryStore,
+ assignmentStore AssignmentStore,
+ conns service.Connections,
+ primaryGetter PrimaryGetter,
+) gitalypb.PraefectInfoServiceServer {
return &Server{
- nodeMgr: nodeMgr,
- conf: conf,
- queue: queue,
- rs: rs,
- rfs: rfs,
+ nodeMgr: nodeMgr,
+ conf: conf,
+ queue: queue,
+ rs: rs,
+ assignmentStore: assignmentStore,
+ conns: conns,
+ primaryGetter: primaryGetter,
}
}