Documentation ¶
Index ¶
- Constants
- Variables
- type Cluster
- type FSM
- func (f *FSM) Apply(l *raft.Log) interface{}
- func (f *FSM) Execute(c *pb.ClusterCommand) interface{}
- func (f *FSM) MarshalBinary() ([]byte, error)
- func (f *FSM) Persist(sink raft.SnapshotSink) error
- func (f *FSM) Release()
- func (f *FSM) Restore(rc io.ReadCloser) error
- func (f *FSM) Snapshot() (raft.FSMSnapshot, error)
- func (f *FSM) UnmarshalBinary(data []byte) error
- type Option
Constants ¶
const PeerListSep = ","
PeerListSep separates peer definitions in the peer list.
const PeerOptsSep = ":"
PeerOptsSep separates a peer's options.
Variables ¶
var ErrClusterConfig = errors.New("invalid cluster configuration")
ErrClusterConfig is the error returned in case of invalid Cluster configuration.
var ErrDeadlineExceeded error = errors.New("deadline exceeded")
ErrDeadlineExceeded is the error returned if a timeout is specified.
var ErrPeerParams = errors.New("invalid peer parameters")
ErrPeerParams is the error returned if the peer parameters are invalid.
var ErrUnknownCommand = errors.New("unknown command")
ErrUnknownCommand is the error returned by fsm.Apply if the command is unknown.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster interface { // Raft returns the raft node for this Cluster. Raft() *raft.Raft // ID returns the Cluster ID ID() string // IsLeader returns true if the Cluster is the leader. IsLeader() bool // LeaderAddress returns address of the current leader of the cluster. LeaderAddress() string // AddVoter adds a new Voter to the cluster. AddVoter(id string, bindIP string, bindPort int) error // LeadershipTransfer will transfer leadership to another Cluster. LeadershipTransfer() error // Leader returns a channel which signals on acquiring or losing // leadership. It sends true if the Cluster become the leader, otherwise it // returns false. Leader() <-chan bool // Execute executes the command c bypassing Raft node. Execute(c *pb.ClusterCommand) interface{} // Done returns a channel that's closed when the Cluster is shutdown. Done() <-chan error }
Cluster is a higher level representation of raft.Raft cluster endpoint.
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
FSM implements raft.FSM
func (*FSM) Execute ¶
func (f *FSM) Execute(c *pb.ClusterCommand) interface{}
Execute executes the command c.
func (*FSM) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.MarshalBinary (https://golang.org/pkg/encoding/#BinaryMarshaler).
func (*FSM) Persist ¶
func (f *FSM) Persist(sink raft.SnapshotSink) error
Persist implements raft.SnapshotSink.Persist.
func (*FSM) Restore ¶
func (f *FSM) Restore(rc io.ReadCloser) error
Restore is used to restore an FSM from a snapshot.
func (*FSM) Snapshot ¶
func (f *FSM) Snapshot() (raft.FSMSnapshot, error)
Snapshot is used to support log compaction.
func (*FSM) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.UnmarshalBinary (https://golang.org/pkg/encoding/#BinaryUnmarshaler).
type Option ¶
type Option func(*options) error
Option defines a Cluster configuration option.
func WithBindAddress ¶
WithBindAddress passes the Cluster's bind address.
func WithLoggerName ¶
WithLoggerName sets the Cluster logger name.
func WithPingPeriod ¶
WithPingPeriod sets the Cluster ping period.