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/assignment.go')
-rw-r--r--internal/praefect/assignment.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/praefect/assignment.go b/internal/praefect/assignment.go
new file mode 100644
index 000000000..f0f38e5af
--- /dev/null
+++ b/internal/praefect/assignment.go
@@ -0,0 +1,33 @@
+package praefect
+
+import (
+ "context"
+ "errors"
+)
+
+// AssignmentStore is the interface which Praefect uses to operate on repository assignments.
+type AssignmentStore interface {
+ AssignmentGetter
+ // SetReplicationFactor sets a repository's replication factor to the desired value and returns the
+ // resulting assignments.
+ SetReplicationFactor(ctx context.Context, virtualStorage, relativePath string, replicationFactor int) ([]string, error)
+}
+
+type disabledAssignments map[string][]string
+
+// NewDisabledAssignmentStore returns an assignments store that can be used if no
+// database is configured. It returns every configured storage as assigned and
+// errors when trying to set assignments.
+func NewDisabledAssignmentStore(storages map[string][]string) AssignmentStore {
+ return disabledAssignments(storages)
+}
+
+// GetHostAssigments simply returns all of the storages configured for the virtual storage.
+func (storages disabledAssignments) GetHostAssignments(ctx context.Context, virtualStorage, relativePath string) ([]string, error) {
+ return storages[virtualStorage], nil
+}
+
+// SetReplicationFactor errors when attempting to set assignments.
+func (disabledAssignments) SetReplicationFactor(context.Context, string, string, int) ([]string, error) {
+ return nil, errors.New("assignments are disabled")
+}