cluster_config.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package server
  2. import (
  3. "time"
  4. )
  5. const (
  6. // DefaultActiveSize is the default number of active followers allowed.
  7. DefaultActiveSize = 9
  8. // MinActiveSize is the minimum active size allowed.
  9. MinActiveSize = 3
  10. // DefaultPromoteDelay is the default elapsed time before promotion.
  11. DefaultPromoteDelay = int((30 * time.Minute) / time.Second)
  12. // MinPromoteDelay is the minimum promote delay allowed.
  13. MinPromoteDelay = int((2 * time.Second) / time.Second)
  14. )
  15. // ClusterConfig represents cluster-wide configuration settings.
  16. // These settings can only be changed through Raft.
  17. type ClusterConfig struct {
  18. // ActiveSize is the maximum number of node that can join as Raft followers.
  19. // Nodes that join the cluster after the limit is reached are proxies.
  20. ActiveSize int `json:"activeSize"`
  21. // PromoteDelay is the amount of time, in seconds, after a node is
  22. // unreachable that it will be swapped out for a proxy node, if available.
  23. PromoteDelay int `json:"promoteDelay"`
  24. }
  25. // NewClusterConfig returns a cluster configuration with default settings.
  26. func NewClusterConfig() *ClusterConfig {
  27. return &ClusterConfig{
  28. ActiveSize: DefaultActiveSize,
  29. PromoteDelay: DefaultPromoteDelay,
  30. }
  31. }