Documentation ¶
Overview ¶
Package store provides a simple distributed key-value store. The keys and associated values are changed via distributed consensus, meaning that the values are changed only when a majority of nodes in the cluster agree on the new value.
Distributed consensus is provided via the Raft algorithm, specifically the Hashicorp implementation.
Index ¶
- type FSM
- type FSMResponse
- type FSMSnapshot
- type Store
- func (s *Store) Acquire(key string, ttl int) error
- func (s *Store) Join(nodeID, addr string) error
- func (s *Store) ListenToLeaderChanges()
- func (s *Store) Open(enableSingle bool, localID string) error
- func (s *Store) Release(key string) error
- func (s *Store) RunValueLogGC()
- func (s *Store) SetLeaderChangeFunc(leaderChangeFn func(bool))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSM ¶
type FSM Store
type FSMResponse ¶
type FSMResponse struct {
// contains filtered or unexported fields
}
type FSMSnapshot ¶
type FSMSnapshot struct {
// contains filtered or unexported fields
}
func (*FSMSnapshot) Persist ¶
func (f *FSMSnapshot) Persist(sink raft.SnapshotSink) error
func (*FSMSnapshot) Release ¶
func (f *FSMSnapshot) Release()
type Store ¶
type Store struct { RaftDir string RaftBind string ServerID raft.ServerID // contains filtered or unexported fields }
Store is a simple key-value store, where all changes are made via Raft consensus.
func (*Store) Acquire ¶
Acquire acquires a lock the given key if it wasn't acquired by somebody else.
func (*Store) Join ¶
Join joins a node, identified by nodeID and located at addr, to this store. The node must be ready to respond to Raft communications at that address.
func (*Store) ListenToLeaderChanges ¶ added in v0.1.14
func (s *Store) ListenToLeaderChanges()
func (*Store) Open ¶
Open opens the store. If enableSingle is set, and there are no existing peers, then this node becomes the first node, and therefore leader, of the cluster. localID should be the server identifier for this node.
func (*Store) RunValueLogGC ¶ added in v0.2.2
func (s *Store) RunValueLogGC()