Documentation
¶
Index ¶
- type Level
- type MemoryStore
- func (s *MemoryStore) Close() error
- func (s *MemoryStore) DeleteRange(min, max uint64) (err error)
- func (s *MemoryStore) FirstIndex() (uint64, error)
- func (s *MemoryStore) Get(key []byte) ([]byte, error)
- func (s *MemoryStore) GetLog(index uint64) (*log.LogEntry, error)
- func (s *MemoryStore) GetUint64(key []byte) (uint64, error)
- func (s *MemoryStore) LastIndex() (uint64, error)
- func (s *MemoryStore) Set(key, val []byte) error
- func (s *MemoryStore) SetUint64(key []byte, val uint64) error
- func (s *MemoryStore) Shrink() error
- func (s *MemoryStore) StoreLogs(logs []*log.LogEntry) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory implementation of the LogStore interface. It can optionally persist the logs to disk.
func (*MemoryStore) DeleteRange ¶
func (s *MemoryStore) DeleteRange(min, max uint64) (err error)
func (*MemoryStore) FirstIndex ¶
func (s *MemoryStore) FirstIndex() (uint64, error)
FirstIndex returns the first index written. 0 for no entries.
func (*MemoryStore) Get ¶
func (s *MemoryStore) Get(key []byte) ([]byte, error)
Get is used to get a value for a given key
func (*MemoryStore) GetLog ¶
func (s *MemoryStore) GetLog(index uint64) (*log.LogEntry, error)
GetLog gets a log entry at a given index.
func (*MemoryStore) GetUint64 ¶
func (s *MemoryStore) GetUint64(key []byte) (uint64, error)
GetUint64 is used to get a value for a given key
func (*MemoryStore) LastIndex ¶
func (s *MemoryStore) LastIndex() (uint64, error)
LastIndex returns the last index written. 0 for no entries.
func (*MemoryStore) Set ¶
func (s *MemoryStore) Set(key, val []byte) error
Set is used to set a key value pair
func (*MemoryStore) SetUint64 ¶
func (s *MemoryStore) SetUint64(key []byte, val uint64) error
SetUint64 is used to set a key value pair
func (*MemoryStore) Shrink ¶
func (s *MemoryStore) Shrink() error
Shrink is used to shrink the storage it is used to shrink the storage when the size of the file is greater than minShrinkSize The storage is shrunk by creating a new file and copying only the logs that are in memory to the new file. The new file is then renamed to the old file.
type Store ¶
type Store interface { // FirstIndex returns the first index written. 0 for no entries. FirstIndex() (uint64, error) // LastIndex returns the last index written. 0 for no entries. LastIndex() (uint64, error) // GetLog gets a log entry at a given index. GetLog(index uint64) (*log.LogEntry, error) // StoreLogs stores multiple log entries. By default the logs stored may not be contiguous with previous logs (i.e. may have a gap in Index since the last log written). If an implementation can't tolerate this it may optionally implement `MonotonicLogStore` to indicate that this is not allowed. This changes Raft's behaviour after restoring a user snapshot to remove all previous logs instead of relying on a "gap" to signal the discontinuity between logs before the snapshot and logs after. StoreLogs(logs []*log.LogEntry) error // DeleteRange deletes a range of log entries. The range is inclusive. DeleteRange(min, max uint64) error // Set is used to set a key value pair Set(key []byte, val []byte) error // Get returns the value for key, or an error. Get(key []byte) ([]byte, error) // SetUint64 is used to set a key value pair SetUint64(key []byte, val uint64) error // GetUint64 returns the value for key, or an error. GetUint64(key []byte) (uint64, error) }
Store is an interface that is used to store the logs