Documentation ¶
Index ¶
- func NewRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), ...) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter)
- func ServeHttpKVAPI(kv *KVStore, port int, confChangeC chan<- raftpb.ConfChange, ...)
- func ServeHttpSDAPI()
- type BoltStorage
- func (bs *BoltStorage) Entries(lo, hi, maxSize uint64) ([]pb.Entry, error)
- func (bs *BoltStorage) FirstIndex() (uint64, error)
- func (bs *BoltStorage) InitialState() (pb.HardState, pb.ConfState, error)
- func (bs *BoltStorage) LastIndex() (uint64, error)
- func (bs *BoltStorage) Snapshot() (pb.Snapshot, error)
- func (bs *BoltStorage) Term(i uint64) (uint64, error)
- type KVStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRaftNode ¶
func NewRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string, confChangeC <-chan raftpb.ConfChange) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter)
newRaftNode initiates a raft instance and returns a committed log entry channel and error channel. Proposals for log updates are sent over the provided the proposal channel. All log entries are replayed over the commit channel, followed by a nil message (to indicate the channel is current), then new log entries. To shutdown, close proposeC and read errorC.
func ServeHttpKVAPI ¶
func ServeHttpKVAPI(kv *KVStore, port int, confChangeC chan<- raftpb.ConfChange, errorC <-chan error)
serveHttpKVAPI starts a key-value server with a GET/PUT API and listens.
func ServeHttpSDAPI ¶
func ServeHttpSDAPI()
serveHttpSDAPI starts a key-value server with a GET/PUT API and listens.
Types ¶
type BoltStorage ¶
BoltStorage implements the Storage interface backed by an boltdb
func NewBoltStorage ¶
func NewBoltStorage(db *bolt.DB) *BoltStorage
func (*BoltStorage) Entries ¶
func (bs *BoltStorage) Entries(lo, hi, maxSize uint64) ([]pb.Entry, error)
Entries returns a slice of log entries in the range [lo,hi). MaxSize limits the total size of the log entries returned, but Entries returns at least one entry if any.
func (*BoltStorage) FirstIndex ¶
func (bs *BoltStorage) FirstIndex() (uint64, error)
FirstIndex returns the index of the first log entry that is possibly available via Entries (older entries have been incorporated into the latest Snapshot; if storage only contains the dummy entry the first log entry is not available).
func (*BoltStorage) InitialState ¶
InitialState returns the saved HardState and ConfState information.
func (*BoltStorage) LastIndex ¶
func (bs *BoltStorage) LastIndex() (uint64, error)
LastIndex returns the index of the last entry in the log.
func (*BoltStorage) Snapshot ¶
func (bs *BoltStorage) Snapshot() (pb.Snapshot, error)
Snapshot returns the most recent snapshot. If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable, so raft state machine could know that Storage needs some time to prepare snapshot and call Snapshot later.
func (*BoltStorage) Term ¶
func (bs *BoltStorage) Term(i uint64) (uint64, error)
Term returns the term of entry i, which must be in the range [FirstIndex()-1, LastIndex()]. The term of the entry before FirstIndex is retained for matching purposes even though the rest of that entry may not be available.
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
a key-value store backed by raft
func NewKVStore ¶
func NewKVStore(snapshotter *snap.Snapshotter, proposeC chan<- string, commitC <-chan *commit, errorC <-chan error) *KVStore