github.com/matm/etcd@v0.3.1-0.20140328024009-5b4a473f1453/server/cluster_config.go (about)

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