forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_config.go
50 lines (39 loc) · 1.59 KB
/
cluster_config.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
package server
import (
"time"
)
const (
// DefaultActiveSize is the default number of active followers allowed.
DefaultActiveSize = 9
// MinActiveSize is the minimum active size allowed.
MinActiveSize = 3
// DefaultRemoveDelay is the default elapsed time before removal.
DefaultRemoveDelay = float64((5 * time.Second) / time.Second)
// MinRemoveDelay is the minimum remove delay allowed.
MinRemoveDelay = float64((2 * time.Second) / time.Second)
// DefaultSyncInterval is the default interval for cluster sync.
DefaultSyncInterval = float64((5 * time.Second) / time.Second)
// MinSyncInterval is the minimum sync interval allowed.
MinSyncInterval = float64((1 * time.Second) / time.Second)
)
// ClusterConfig represents cluster-wide configuration settings.
// These settings can only be changed through Raft.
type ClusterConfig struct {
// ActiveSize is the maximum number of node that can join as Raft followers.
// Nodes that join the cluster after the limit is reached are standbys.
ActiveSize int `json:"activeSize"`
// RemoveDelay is the amount of time, in seconds, after a node is
// unreachable that it will be swapped out as a standby node.
RemoveDelay float64 `json:"removeDelay"`
// SyncInterval is the amount of time, in seconds, between
// cluster sync when it runs in standby mode.
SyncInterval float64 `json:"syncInterval"`
}
// NewClusterConfig returns a cluster configuration with default settings.
func NewClusterConfig() *ClusterConfig {
return &ClusterConfig{
ActiveSize: DefaultActiveSize,
RemoveDelay: DefaultRemoveDelay,
SyncInterval: DefaultSyncInterval,
}
}