cluster_config.go 1009 B

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