config

package
v0.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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 State

type State struct {
	// 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) ElectionTimeout

func (c *State) ElectionTimeout() time.Duration

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.

func (*State) HeartbeatTimeout

func (c *State) HeartbeatTimeout() time.Duration

HeartbeatTimeout is the amount of time between heartbeat messages from the leader to other nodes.

func (*State) Load

func (c *State) Load(buf []byte) error

Load replaces the current configuration from a bunch of YAML.

func (*State) LoadFile

func (c *State) LoadFile(fileName string) error

LoadFile loads configuration from a file.

func (*State) Lock

func (c *State) Lock()

Lock locks the internal latch just like a Mutex

func (*State) MinPurgeDuration

func (c *State) MinPurgeDuration() time.Duration

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.

func (*State) MinPurgeRecords

func (c *State) MinPurgeRecords() uint32

MinPurgeRecords defines the minimum number of records that must be retained on a purge. Default is zero, which means no purging.

func (*State) RLock

func (c *State) RLock()

RLock locks the internal latch just like an RWMutex

func (*State) RUnlock

func (c *State) RUnlock()

RUnlock unlocks the internal latch just like an RWMutex

func (*State) SetElectionTimeout added in v0.5.5

func (c *State) SetElectionTimeout(d time.Duration)

SetElectionTimeout updates ElectionTimeout in a thread-safe way.

func (*State) SetHeartbeatTimeout added in v0.5.5

func (c *State) SetHeartbeatTimeout(d time.Duration)

SetHeartbeatTimeout updates HeartbeatTimeout in a thread-safe way.

func (*State) SetMinPurgeDuration added in v0.5.5

func (c *State) SetMinPurgeDuration(d time.Duration)

SetMinPurgeDuration updates MinPurgeDuration in a thread-safe way.

func (*State) SetMinPurgeRecords added in v0.5.5

func (c *State) SetMinPurgeRecords(v uint32)

SetMinPurgeRecords updates MinPurgeRecords in a thread-safe way.

func (*State) SetWebHooks added in v0.5.5

func (c *State) SetWebHooks(h []hooks.WebHook)

SetWebHooks updates the web hooks in a thread-safe way.

func (*State) ShouldPurgeRecords

func (c *State) ShouldPurgeRecords() bool

ShouldPurgeRecords is a convenience that lets us know if both parameters are set to cause automatic purging to happen.

func (*State) Store

func (c *State) Store() ([]byte, error)

Store returns the encoded configuration as a byte slice.

func (*State) StoreFile

func (c *State) StoreFile(fileName string) error

StoreFile writes the configuration to a file.

func (*State) Timeouts added in v0.5.5

func (c *State) Timeouts() (time.Duration, time.Duration)

Timeouts is a quick way to get the election and heartbeat timeouts in one call. The first one returned is the heartbeat timeout, then election timeout.

func (*State) Unlock

func (c *State) Unlock()

Unlock unlocks the internal latch just like a Mutex

func (*State) Validate

func (c *State) Validate() error

Validate parses some of the strings in the configuration and it also returns an error if basic parameters are not met.

func (*State) WebHooks

func (c *State) WebHooks() []hooks.WebHook

WebHooks are a list of hooks that we might invoke before persisting a change

type StoredState added in v0.5.5

type StoredState struct {
	MinPurgeRecords  uint32          `yaml:"minPurgeRecords"`
	MinPurgeDuration string          `yaml:"minPurgeDuration"`
	ElectionTimeout  string          `yaml:"electionTimeout"`
	HeartbeatTimeout string          `yaml:"heartbeatTimeout"`
	WebHooks         []hooks.WebHook `yaml:"webHooks,omitempty"`
}

StoredState is the structure that is read from and written to YAML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL