blob: c2c9b19c07d95239aa4b4416f315056144d13445 (
plain)
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
|
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)
}
// GetHostAssignments simply returns all of the storages configured for the virtual storage.
func (storages disabledAssignments) GetHostAssignments(ctx context.Context, virtualStorage string, repositoryID int64) ([]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")
}
|