raftsqlite3

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2019 License: MPL-2.0 Imports: 13 Imported by: 0

README

raft-sqlite3

This repository provides the raftsqlite3 package. The package exports the Sqlite3Store which is an implementation of both a LogStore and StableStore.

It is meant to be used as a backend for the raft package here.

This implementation uses SQLite3. SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// An error indicating a given key does not exist
	ErrKeyNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type Sqlite3Store

type Sqlite3Store struct {
	// contains filtered or unexported fields
}

Sqlite3Store provides access to sqlite3 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(dataSourceName string) (*Sqlite3Store, error)

New uses the supplied dataSourceName to open the sqlite3 and prepare it for use as a raft backend.

func NewSqlite3Store

func NewSqlite3Store(dataSourceName string) (*Sqlite3Store, error)

func (*Sqlite3Store) Close

func (s *Sqlite3Store) Close() error

Close is used to gracefully close the DB connection.

func (*Sqlite3Store) DeleteRange

func (s *Sqlite3Store) DeleteRange(min, max uint64) error

DeleteRange is used to delete logs within a given range inclusively.

func (*Sqlite3Store) FirstIndex

func (s *Sqlite3Store) FirstIndex() (uint64, error)

FirstIndex returns the first known index from the Raft log.

func (*Sqlite3Store) Get

func (s *Sqlite3Store) Get(k []byte) ([]byte, error)

Get is used to retrieve a value from the k/v store by key

func (*Sqlite3Store) GetLog

func (s *Sqlite3Store) GetLog(idx uint64, log *raft.Log) error

GetLog is used to retrieve a log from sqlite3 at a given index.

func (*Sqlite3Store) GetUint64

func (s *Sqlite3Store) GetUint64(key []byte) (uint64, error)

GetUint64 is like Get, but handles uint64 values

func (*Sqlite3Store) LastIndex

func (s *Sqlite3Store) LastIndex() (uint64, error)

LastIndex returns the last known index from the Raft log.

func (*Sqlite3Store) Set

func (s *Sqlite3Store) Set(k, v []byte) error

Set is used to set a key/value set outside of the raft log

func (*Sqlite3Store) SetUint64

func (s *Sqlite3Store) SetUint64(key []byte, val uint64) error

SetUint64 is like Set, but handles uint64 values

func (*Sqlite3Store) StoreLog

func (s *Sqlite3Store) StoreLog(log *raft.Log) error

StoreLog is used to store a single raft log

func (*Sqlite3Store) StoreLogs

func (s *Sqlite3Store) StoreLogs(logs []*raft.Log) (err error)

StoreLogs is used to store a set of raft logs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL