Documentation
¶
Index ¶
- Variables
- func DecodeMsgPack(data []byte, v interface{}) error
- func EncodeMsgPack(v interface{}, useNewTimeFormat bool) (*bytes.Buffer, error)
- func End(prefix []byte) []byte
- type BadgerRaftStore
- func (b *BadgerRaftStore) Close() error
- func (b *BadgerRaftStore) DeleteRange(min, max uint64) error
- func (b *BadgerRaftStore) FirstIndex() (uint64, error)
- func (b *BadgerRaftStore) Get(k []byte) ([]byte, error)
- func (b *BadgerRaftStore) GetLog(idx uint64, raftLog *raft.Log) error
- func (b *BadgerRaftStore) GetUint64(key []byte) (uint64, error)
- func (b *BadgerRaftStore) LastIndex() (uint64, error)
- func (b *BadgerRaftStore) RunValueLogGC(discardRatio float64) error
- func (b *BadgerRaftStore) Set(k, v []byte) error
- func (b *BadgerRaftStore) SetUint64(key []byte, val uint64) error
- func (b *BadgerRaftStore) Size() (lsm, vlog int64)
- func (b *BadgerRaftStore) StoreLog(l *raft.Log) error
- func (b *BadgerRaftStore) StoreLogs(logs []*raft.Log) error
- type Options
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // An error indicating a given key does not exist ErrKeyNotFound = errors.New("not found") )
Functions ¶
func DecodeMsgPack ¶
DecodeMsgPack decodes data into v using msgpack.
func EncodeMsgPack ¶
EncodeMsgPack encodes v into msgpack bytes. The useNewTimeFormat flag is accepted for API compatibility but this helper uses the default encoder.
Types ¶
type BadgerRaftStore ¶
type BadgerRaftStore struct {
// contains filtered or unexported fields
}
BadgerRaftStore provides access to Badger for Raft to store and retrieve log entries. It also provides key/value storage, and can be used as a LogStore and StableStore.
func New ¶
func New(db *badger.DB, options Options) (*BadgerRaftStore, error)
New uses the supplied already-opened DB to create the BadgerRaftStore.
func NewBadgerRaftStore ¶
func NewBadgerRaftStore(path string) (*BadgerRaftStore, error)
NewBadgerRaftStore takes a file path and returns a connected Raft backend. This convenience function uses default options. If you want to set options such as NoSync, use NewBadgerRaftStoreWithOptions.
func NewBadgerRaftStoreWithOptions ¶ added in v0.2.0
func NewBadgerRaftStoreWithOptions(path string, options Options) (*BadgerRaftStore, error)
NewBadgerRaftStoreWithOptions opens a Badger DB at path applying provided options.
func (*BadgerRaftStore) Close ¶
func (b *BadgerRaftStore) Close() error
Close is used to gracefully close the DB connection.
func (*BadgerRaftStore) DeleteRange ¶
func (b *BadgerRaftStore) DeleteRange(min, max uint64) error
DeleteRange is used to delete logs within a given range inclusively.
func (*BadgerRaftStore) FirstIndex ¶
func (b *BadgerRaftStore) FirstIndex() (uint64, error)
FirstIndex returns the first known index from the Raft log.
func (*BadgerRaftStore) Get ¶
func (b *BadgerRaftStore) Get(k []byte) ([]byte, error)
Get is used to retrieve a value from the k/v store by key
func (*BadgerRaftStore) GetLog ¶
func (b *BadgerRaftStore) GetLog(idx uint64, raftLog *raft.Log) error
GetLog is used to retrieve a log from badger at a given index.
func (*BadgerRaftStore) GetUint64 ¶
func (b *BadgerRaftStore) GetUint64(key []byte) (uint64, error)
GetUint64 is like Get, but handles uint64 values
func (*BadgerRaftStore) LastIndex ¶
func (b *BadgerRaftStore) LastIndex() (uint64, error)
LastIndex returns the last known index from the Raft log.
func (*BadgerRaftStore) RunValueLogGC ¶
func (b *BadgerRaftStore) RunValueLogGC(discardRatio float64) error
func (*BadgerRaftStore) Set ¶
func (b *BadgerRaftStore) Set(k, v []byte) error
Set is used to set a key/value set outside of the raft log
func (*BadgerRaftStore) SetUint64 ¶
func (b *BadgerRaftStore) SetUint64(key []byte, val uint64) error
SetUint64 is like Set, but handles uint64 values
func (*BadgerRaftStore) Size ¶
func (b *BadgerRaftStore) Size() (lsm, vlog int64)
type Options ¶
type Options struct {
// NoSync causes the database to skip fsync calls after each
// write to the log. This is unsafe, so it should be used
// with caution.
NoSync bool
// MsgpackUseNewTimeFormat when set to true, force the underlying msgpack
// codec to use the new format of time.Time when encoding (used in
// go-msgpack v1.1.5 by default). Decoding is not affected, as all
// go-msgpack v2.1.0+ decoders know how to decode both formats.
MsgpackUseNewTimeFormat bool
}
Options contains all the configuration used to open the Badger
type Store ¶ added in v0.1.1
type Store interface {
Close() error
FirstIndex() (uint64, error)
LastIndex() (uint64, error)
GetLog(idx uint64, log *raft.Log) error
StoreLog(log *raft.Log) error
StoreLogs(logs []*raft.Log) error
DeleteRange(min, max uint64) error
Set(k, v []byte) error
Get(k []byte) ([]byte, error)
SetUint64(key []byte, val uint64) error
GetUint64(key []byte) (uint64, error)
RunValueLogGC(discardRatio float64) error
Size() (lsm, vlog int64)
}