Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Operation Operation `json:"command"` Key string `json:"key"` Value string `json:"value,omitempty"` }
func GetCommand ¶
GetCommand: creates an Command object from raw byte data
type ErrUnknownCommand ¶
type ErrUnknownCommand struct {
// contains filtered or unexported fields
}
func (*ErrUnknownCommand) Error ¶
func (err *ErrUnknownCommand) Error() string
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore is the distributed Key-value store It uses `Raft` internally to get consensus from the peers
func New ¶
Create new KeyStore. bootstrap_cluster is flag; whether to create a Raft cluster. This only needs to be ran once in the lifespan of a cluster
func (*KeyStore) Delete ¶
Delete, deletes the given key in highly consistent manner
It must be called through leader otherwise it will return an error
func (*KeyStore) GetOrCreate ¶
GetOrCreate, gets the given key or creates incase it doesn't exist in highly consistent manner
It must be called through leader otherwise it will return an error returns: created, value, error
type KeyStoreFSM ¶
type KeyStoreFSM KeyStore
KeyStoreFSM implements the raft.FSM interface for the KeyStore
It is basically a KeyStore, but it's FSM implementation is extracted out for maintainablity purpose.
func (*KeyStoreFSM) Apply ¶
func (store *KeyStoreFSM) Apply(log *raft_lib.Log) interface{}
Apply is called once a log entry is committed by a majority of the cluster.
Apply should apply the log to the FSM. Apply must be deterministic and produce the same result on all peers in the cluster.
The returned value is returned to the client as the ApplyFuture.Response.
func (*KeyStoreFSM) Restore ¶
func (store *KeyStoreFSM) Restore(snapshot io.ReadCloser) error
Implements Restore, It will restore the snapshopt back to the KeyStore
func (*KeyStoreFSM) Snapshot ¶
func (store *KeyStoreFSM) Snapshot() (raft_lib.FSMSnapshot, error)
Implements Snapshot, this helps raft to not have unbounded logs, And data can be recovered later on
type KeyStoreSnapshot ¶
type KeyStoreSnapshot struct {
// contains filtered or unexported fields
}
KeyStoreSnapshot holds snapshot data returned by FSM, which will be saved to the SnapshotStore which then later can be recoved.
func (*KeyStoreSnapshot) Persist ¶
func (snap *KeyStoreSnapshot) Persist(sink raft_lib.SnapshotSink) error
Persist is an implementation to write Snapshot data so that it can be saved
func (*KeyStoreSnapshot) Release ¶
func (snap *KeyStoreSnapshot) Release()
This implements Release, it will be called when we will be done with the snapshot