Documentation ¶
Overview ¶
Package localdb is a wrapper around bbolt key-value database to manage messaging data in a local database Its primary purpose is to be used persist messages if sending queues like NATS fails.
Index ¶
- Variables
- type ChunkData
- type LocalDB
- func (db *LocalDB) Close() error
- func (db *LocalDB) Count(bucket string) (int, error)
- func (db *LocalDB) CutChunkDown(bucket string, max int) ([]ChunkData, error)
- func (db *LocalDB) CutChunkUp(bucket string, max int) ([]ChunkData, error)
- func (db *LocalDB) Delete(bucket string, key string) error
- func (db *LocalDB) DeleteOnce(bucket string, key []string) error
- func (db *LocalDB) Fetch(bucket string, key string) (data []byte, err error)
- func (db *LocalDB) FetchChunkDown(bucket string, max int, offset int) ([]ChunkData, error)
- func (db *LocalDB) FetchChunkUp(bucket string, max int, offset int) ([]ChunkData, error)
- func (db *LocalDB) FetchDelete(bucket string, key string) ([]byte, error)
- func (db *LocalDB) SliceDown(bucket string) (data []byte, err error)
- func (db *LocalDB) SliceUp(bucket string) (data []byte, err error)
- func (db *LocalDB) Store(bucket string, key string, data []byte) error
- func (db *LocalDB) StoreOnce(bucket string, data []ChunkData) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrLocalDatabaseNotYetOpened = errors.New(`local database not yet opened`) ErrCorruptedInternalBucket = errors.New(`corrupted internal bucket`) ErrBucketDoesNotExist = errors.New(`bucket does not exist`) ErrNoKeysSet = errors.New(`no keys set`) )
Errors
Functions ¶
This section is empty.
Types ¶
type LocalDB ¶
type LocalDB struct { FileName string // contains filtered or unexported fields }
LocalDB is a wrapper around bbolt key-value database to manage messaging data in a local database
func (*LocalDB) CutChunkDown ¶
CutChunkDown gets chunk of data from the bucket from top to bottom in ascending order and removes them.
func (*LocalDB) CutChunkUp ¶
CutChunkUp gets chunk of data from the bucket from bottom to top in descending order and removes them.
func (*LocalDB) DeleteOnce ¶
DeleteOnce deletes data in the local database in one go
func (*LocalDB) FetchChunkDown ¶
FetchChunkDown gets chunk of data starting from the top to bottom limited by max
func (*LocalDB) FetchChunkUp ¶
FetchChunkUp gets chunk of data starting from the bottom to top limited by max
func (*LocalDB) FetchDelete ¶
FetchDelete fetches the data in the key and deletes it