Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingReplicaID = errors.New("invalid raft configuration: local replica id is required") ErrMissingField = errors.New("invalid raft configuration: tick and timeout are required and one of peers path or quorum") ErrTickTooSmall = errors.New("invalid raft configuration: tick must be greater than 10ms") ErrTimeoutTooBig = errors.New("invalid raft configuration: timeout must be smaller than the tick") ErrMissingReplica = errors.New("invalid raft configuration: local replica is not defined in the quorum") )
Validation Errors
View Source
var (
ErrCannotSetRunningState = errors.New("can only set the running state from the initialized state")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ReplicaID uint32 `required:"true"` // the process ID of the local replica to identify from the peers config Tick time.Duration `default:"1s"` // the tick interval used to compute the heartbeat and election timeouts Timeout time.Duration `default:"500ms"` // the timeout to wait for a response from a peer Aggregate bool `default:"true"` // aggregate multiple commands into one append entries PeersPath string `split_words:"true"` // the path to the peers configuration (usually loaded from a config map), only loaded if quorum is nil Quorum *peers.Quorum `ignored:"true"` // the peers configuration, will not be loaded from the environment }
Config is intended to be loaded from the environment using confire and embedded as an subconfiguration of the service configuration (not loaded directly).
type Replica ¶
type Replica struct { api.UnimplementedRaftServer peers.Peer // contains filtered or unexported fields }
func New ¶
New creates a new replica from the configuration, validating it and setting the replica to its initialized state. If the configuration is invalid or the replica cannot be correctly initialized then an error is returned.
Click to show internal directories.
Click to hide internal directories.