goraft

package module
v0.0.0-...-2ad55f5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NodeID            string `toml:"node_id"`
	ListenAddr        string `toml:"listen_addr"`
	DataDir           string `toml:"data_dir"`
	CompactionEnabled bool   `toml:"compaction_enabled"`
	Peers             []Peer `toml:"peers"`
}

Config defines a node's configuration needed for Raft consensus bootstrapping and cluster management.

func LoadConfigFromFile

func LoadConfigFromFile(filepath string) (cfg Config, err error)

LoadConfigFromFile attempts to load a configuration from file. It returns an error upon failure of reading or parsing the file.

func (Config) Validate

func (cfg Config) Validate() error

Validate performs basic validation of a node's configuration.

type Logger

type Logger interface {
	Info(msg string, args ...interface{})
	Debug(msg string, args ...interface{})
	Error(msg string, args ...interface{})
	With(args ...interface{}) Logger
}

Logger defines a logging interface a Raft node expects to use.

func NewRaftLogger

func NewRaftLogger(w io.Writer) Logger

type Peer

type Peer struct {
	NodeID  string `toml:"node_id"`
	Address string `toml:"address"`
}

Peer defines a node's peer in a cluster configuration.

func (Peer) Validate

func (p Peer) Validate() error

Validate performs basic validation of a peer configuration.

type StateMachine

type StateMachine interface {
	Apply(command []byte) (interface{}, error)
}

StateMachine defines an interface that any finite state machine used in Raft must implement. The state machine can be completely agnostic to the mechanics of Raft. It consumes commands from Raft log entries and returns any interface value resulting in success or a potential error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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