Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound error = fmt.Errorf("item not found")
Functions ¶
This section is empty.
Types ¶
type FSM ¶
type FSM struct { VMs map[string]int `json:"vms,omitempty" yaml:"vms,omitempty"` // contains filtered or unexported fields }
FSM is a Raft Finite State Machine (FSM).
func (*FSM) Apply ¶
Apply log is invoked once a Raft log entry is committed. It returns a value which will be made available in the ApplyFuture returned by Raft.Apply method if that method was called on the same Raft node as the FSM.
func (*FSM) Get ¶
Get retrieves an item from the internal store, if available; it does not have to go through the Leader, since all Followers have the same data as the Leader and there is no mutation involved.
func (*FSM) Persist ¶
func (f *FSM) Persist(sink raft.SnapshotSink) error
Persist should write all items to the given sink and then close it; it might acquire a lock to prevent concurrent updates, since it this function could be called with concurrent calls to Apply
func (*FSM) Release ¶
func (f *FSM) Release()
Release is invoked when we are finished with the snapshot; it could be used to release a lock that might have been acquired when starting to Persist (to avoid problems with concurrent calls to Apply).
func (*FSM) Restore ¶
func (f *FSM) Restore(reader io.ReadCloser) error
Restore is called to erase the current FSM internal status and to load it with external data as per the provided reader.
func (*FSM) Snapshot ¶
func (f *FSM) Snapshot() (raft.FSMSnapshot, error)
Snapshot will be called to create a snapshot of the FSM internal status; it must return an object that is capable of saving the FSM internal status while there MAY be concurrent calls to Apply; in our simplistic case, the FSM is capable of snapshotting itself.