-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.go
56 lines (50 loc) · 1.24 KB
/
site.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
package main
type site struct {
Node *node
Cluster *cluster
Backend backend
Replication int
MaxReplication int
ClusterSecret string
AAEInterval int
verifier verifier
rebalancer *rebalancer
}
func newSite(n *node, c *cluster, b backend, replication, maxReplication int, clusterSecret string, aaeInterval int) *site {
// couple sanity checks
if replication < 1 {
replication = 1
}
if maxReplication < replication {
maxReplication = replication
}
if aaeInterval < 1 {
// unset. default to 5 seconds
aaeInterval = 5
}
s := &site{
Node: n,
Cluster: c,
Backend: b,
Replication: replication,
MaxReplication: maxReplication,
ClusterSecret: clusterSecret,
AAEInterval: aaeInterval,
}
s.verifier = b.NewVerifier(c)
s.rebalancer = newRebalancer(c, *s)
return s
}
func (s site) ActiveAntiEntropy() {
// it's the backend's responsibility
s.Backend.ActiveAntiEntropy(s.Cluster, s, s.AAEInterval)
}
func (s site) Rebalance(key key) error {
return s.rebalancer.Rebalance(key)
}
func (s site) Verify(path string, key key, h string) error {
return s.verifier.Verify(path, key, h)
}
func (s site) VerifyKey(key key) error {
return s.verifier.VerifyKey(key)
}