Documentation
¶
Index ¶
- Constants
- type InternalState
- type State
- func (c *State) Internal() *InternalState
- func (c *State) Load(buf []byte) error
- func (c *State) LoadFile(fileName string) error
- func (c *State) Lock()
- func (c *State) RLock()
- func (c *State) RUnlock()
- func (c *State) ShouldPurgeRecords() bool
- func (c *State) Store() ([]byte, error)
- func (c *State) StoreFile(fileName string) error
- func (c *State) Unlock()
- func (c *State) Validate() error
Constants ¶
const ( // DefaultElectionTimeout is the election timeout out of the box. // It may be modified using UpdateRaftConfig DefaultElectionTimeout = "10s" // DefaultHeartbeatTimeout is the default heartbeat timeout. It may be // modified using UpdateRaftConfig DefaultHeartbeatTimeout = "2s" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InternalState ¶
type InternalState struct {
// PurgeDuration is parsed from MinPurgeDuration
PurgeDuration time.Duration
// ElectionDuration is parsed from ElectionTimeout
ElectionDuration time.Duration
// HeartbeatDuration is parsed from HeartbeatTimeout
HeartbeatDuration time.Duration
}
InternalState holds stuff that's not persisted in YAML.
type State ¶
type State struct {
// MinPurgeRecords defines the minimum number of records that must be
// retained on a purge. Default is zero, which means no purging.
MinPurgeRecords uint32 `yaml:"minPurgeRecords"`
// MinPurgeDuration defines the minimum amount of time that a record must
// remain on the change list before being purged. Default is zero, which
// no purging.
MinPurgeDuration string `yaml:"minPurgeDuration"`
// ElectionTimeout is the amount of time a node will wait once it has heard
// from the current leader before it declares itself a candidate.
// It must always be a small multiple of HeartbeatTimeout.
ElectionTimeout string `yaml:"electionTimeout"`
// HeartbeatTimeout is the amount of time between heartbeat messages from the
// leader to other nodes.
HeartbeatTimeout string `yaml:"heartbeatTimeout"`
// WebHooks are a list of hooks that we might invoke before persisting a
// change
WebHooks []hooks.WebHook `yaml:"webHooks,omitempty"`
// contains filtered or unexported fields
}
State describes configuration information about the raft service that is shared around the cluster. If either MinPurgeRecords OR MinPurgeDuration is set to greater than zero, then the leader will send a purge request to the quorum every so often. A State is also an RWMutex so that it can (and should) be locked and unlocked on each go-around.
func GetDefaultConfig ¶
func GetDefaultConfig() *State
GetDefaultConfig should be used as the basis for any configuration changes.
func (*State) Internal ¶
func (c *State) Internal() *InternalState
Internal returns another set of config params that aren't directly persisted to YAML but parsed instead.
func (*State) RUnlock ¶
func (c *State) RUnlock()
RUnlock unlocks the internal latch just like an RWMutex
func (*State) ShouldPurgeRecords ¶
ShouldPurgeRecords is a convenience that lets us know if both parameters are set to cause automatic purging to happen.