boltdb

package
v0.0.0-...-efb87f3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltStore

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

BoltStore is the lowest level of the gansoi database, it represent the on-disk database. BoltStore implements raft.FSM and database.Reader.

func NewBoltStore

func NewBoltStore(path string) (*BoltStore, error)

NewBoltStore will instantiate a new BoltStore. path will be created if it doesn't exist.

func (*BoltStore) All

func (d *BoltStore) All(to interface{}, limit int, skip int, reverse bool) error

All lists all kinds of a type.

func (*BoltStore) Apply

func (d *BoltStore) Apply(l *raft.Log) interface{}

Apply implements raft.FSM.

func (*BoltStore) BroadcastFrom

func (d *BoltStore) BroadcastFrom(index uint64)

BroadcastFrom will set a broadcast "epoch". Raft logs before this epoch will not trigger a PostApply() broadcast. If this is never called nothing will be broadcast.

func (*BoltStore) Close

func (d *BoltStore) Close() error

Close will close the database. Accessing the database after this will result in a deadlock.

func (*BoltStore) Find

func (d *BoltStore) Find(field string, value interface{}, to interface{}, limit int, skip int, reverse bool) error

Find Find returns one or more records by the specified index.

func (*BoltStore) One

func (d *BoltStore) One(fieldName string, value interface{}, to interface{}) error

One will retrieve one (or zero) record from the database.

func (*BoltStore) ProcessLogEntry

func (d *BoltStore) ProcessLogEntry(entry *database.LogEntry) error

ProcessLogEntry will process the log entry and apply whatever needs doing.

func (*BoltStore) RegisterListener

func (d *BoltStore) RegisterListener(listener database.Listener)

RegisterListener implements database.Database.

func (*BoltStore) Restore

func (d *BoltStore) Restore(source io.ReadCloser) error

Restore implements raft.FSM.

func (*BoltStore) Snapshot

func (d *BoltStore) Snapshot() (raft.FSMSnapshot, error)

Snapshot implements raft.FSM.

func (*BoltStore) Storm

func (d *BoltStore) Storm() *storm.DB

Storm will return the underlying Storm database.

func (*BoltStore) WriteTo

func (d *BoltStore) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo. WriteTo will write a consitent snapshot of the database to w.

type Snapshot

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

Snapshot allows raft to retrieve a complete snapshot of the database.

func (*Snapshot) Persist

func (s *Snapshot) Persist(sink raft.SnapshotSink) error

Persist implements raft.FSMSnapshot.

func (*Snapshot) Release

func (s *Snapshot) Release()

Release implements raft.FSMSnapshot.

type TestStore

type TestStore struct {
	BoltStore

	FailSave bool
	// contains filtered or unexported fields
}

TestStore can be used when testing database functions.

func NewTestStore

func NewTestStore() *TestStore

NewTestStore returns a store suited for testing.

func (*TestStore) Close

func (t *TestStore) Close() error

Close will delete the underlying file and close the database.

func (*TestStore) Delete

func (t *TestStore) Delete(data interface{}) error

Delete an object from the database.

func (*TestStore) RegisterListener

func (t *TestStore) RegisterListener(listener database.Listener)

RegisterListener implements database.Broadcaster - but does nothing.

func (*TestStore) Save

func (t *TestStore) Save(data interface{}) error

Save will save an object to the database.

Jump to

Keyboard shortcuts

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