Documentation
¶
Index ¶
- Constants
- Variables
- type BoltDB
- func (b *BoltDB) Bucket(name []byte) *Bucket
- func (b *BoltDB) Close() error
- func (b *BoltDB) DeleteRange(min, max uint64) error
- func (b *BoltDB) FirstIndex() (uint64, error)
- func (b *BoltDB) Get(key []byte) ([]byte, error)
- func (b *BoltDB) GetLog(index uint64, log *raft.Log) error
- func (b *BoltDB) GetUint64(key []byte) (uint64, error)
- func (b *BoltDB) LastIndex() (uint64, error)
- func (b *BoltDB) Set(key []byte, val []byte) error
- func (b *BoltDB) SetUint64(key []byte, val uint64) error
- func (b *BoltDB) StoreLog(log *raft.Log) error
- func (b *BoltDB) StoreLogs(logs []*raft.Log) error
- type Bucket
- type Command
- type FSM
- type FSMSnapshot
- type Item
- type Logger
- type Options
- type Store
Constants ¶
const ( SET = "set" GET = "get" DEL = "del" )
Variables ¶
var ( // An error indicating a given key does not exist ErrKeyNotFound = errors.New("not found") ErrBucketNotFound = errors.New("bucket is not exist") )
buckets
var ( Timeout = 10 * time.Second DataName = "raft.db" )
var (
ErrUnknownCommand = errors.New("unknown command")
)
Functions ¶
This section is empty.
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
func (*BoltDB) DeleteRange ¶
DeleteRange deletes a range of log entries. The range is inclusive.
func (*BoltDB) FirstIndex ¶
FirstIndex returns the first index written. 0 for no entries.
type FSM ¶
FSM provides an interface that can be implemented by clients to make use of the replicated log.
func (*FSM) Apply ¶
Apply log is invoked once a 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) Restore ¶
func (f *FSM) Restore(reader io.ReadCloser) error
Restore is used to restore an FSM from a snapshot. It is not called concurrently with any other command. The FSM must discard all previous state.
func (*FSM) Snapshot ¶
func (f *FSM) Snapshot() (raft.FSMSnapshot, error)
Snapshot is used to support log compaction. This call should return an FSMSnapshot which can be used to save a point-in-time snapshot of the FSM. Apply and Snapshot are not called in multiple threads, but Apply will be called concurrently with Persist. This means the FSM should be implemented in a fashion that allows for concurrent updates while a snapshot is happening.
type FSMSnapshot ¶
type FSMSnapshot struct {
// contains filtered or unexported fields
}
FSMSnapshot is returned by an FSM in response to a Snapshot It must be safe to invoke FSMSnapshot methods with concurrent calls to Apply.
func (*FSMSnapshot) Persist ¶
func (f *FSMSnapshot) Persist(sink raft.SnapshotSink) error
Persist should dump all necessary state to the WriteCloser 'sink', and call sink.Close() when finished or call sink.Cancel() on error.
func (*FSMSnapshot) Release ¶
func (f *FSMSnapshot) Release()
Release is invoked when we are finished with the snapshot.