config

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 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 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) 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) 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) 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) 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.

Jump to

Keyboard shortcuts

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