Documentation ¶
Index ¶
- Variables
- func SetDefaultPogrebOptions(pogrebopts ...any) (err error)
- type CombinedMetrics
- type DB
- func (db *DB) AllStores() map[string]database.Filer
- func (db *DB) BackupAll(archivePath string) (models.Backup, error)
- func (db *DB) Close(storeName string) error
- func (db *DB) CloseAll() error
- func (db *DB) Destroy(name string) error
- func (db *DB) Discover() ([]string, error)
- func (db *DB) Init(storeName string, opts ...any) error
- func (db *DB) Meta() models.Metadata
- func (db *DB) Path() string
- func (db *DB) RestoreAll(archivePath string) error
- func (db *DB) Sync(storeName string) error
- func (db *DB) SyncAll() error
- func (db *DB) SyncAndCloseAll() error
- func (db *DB) Type() string
- func (db *DB) UpdateMetrics()
- func (db *DB) With(storeName string) database.Filer
- func (db *DB) WithNew(storeName string, opts ...any) database.Filer
- type Metrics
- type Option
- type Store
- func (pstore *Store) Backend() any
- func (pstore *Store) Close() error
- func (pstore *Store) Get(key []byte) ([]byte, error)
- func (pstore *Store) Has(key []byte) bool
- func (pstore *Store) Keys() [][]byte
- func (pstore *Store) Len() int
- func (pstore *Store) PrefixScan(prefixs string) (<-chan kv.KeyValue, chan error)
- func (pstore *Store) Search(query string) (<-chan kv.KeyValue, chan error)
- func (pstore *Store) ValueExists(value []byte) (key []byte, ok bool)
- type WrappedOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownAction = errors.New("unknown action") ErrBogusStore = errors.New("bogus store backend") ErrBadOptions = errors.New("invalid pogreb options") ErrStoreExists = errors.New("store name already exists") ErrNoStores = errors.New("no stores initialized") )
var ErrInvalidOptions = errors.New("invalid pogreb options")
var OptionAllowRecovery = func(opts *WrappedOptions) { opts.AllowRecovery = true }
Functions ¶
func SetDefaultPogrebOptions ¶
SetDefaultPogrebOptions options will set the options used for all subsequent pogreb stores that are initialized.
Types ¶
type CombinedMetrics ¶ added in v0.4.2
type CombinedMetrics struct { Puts int64 `json:"puts"` Dels int64 `json:"dels"` Gets int64 `json:"gets"` HashCollisions int64 `json:"hash_collisions"` }
func CombineMetrics ¶ added in v0.4.2
func CombineMetrics(metrics ...*pogreb.Metrics) *CombinedMetrics
func (*CombinedMetrics) Equal ¶ added in v0.4.2
func (cm *CombinedMetrics) Equal(other *CombinedMetrics) bool
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a mapper of a Filer and Searcher implementation using pogreb.
func OpenDB ¶
OpenDB will either open an existing set of pogreb datastores at the given directory, or it will create a new one.
func (*DB) AllStores ¶
AllStores returns a map of the names of all pogreb datastores and the corresponding Filers.
func (*DB) Destroy ¶ added in v0.4.2
Destroy will remove a pogreb store and all data associated with it.
func (*DB) Discover ¶
Discover will discover and initialize all existing bitcask stores at the path opened by OpenDB.
func (*DB) RestoreAll ¶ added in v0.4.2
func (*DB) SyncAll ¶
SyncAll syncs all pogreb datastores. TODO: investigate locking here, right now if we try to hold a lock during a backup we'll hang :^)
func (*DB) SyncAndCloseAll ¶
SyncAndCloseAll implements the method from Keeper to sync and close all bitcask stores.
func (*DB) UpdateMetrics ¶ added in v0.4.2
func (db *DB) UpdateMetrics()
type Option ¶
type Option func(*WrappedOptions)
func AllowRecovery ¶
func AllowRecovery() Option
func SetPogrebOptions ¶
type Store ¶
Store is an implmentation of a Filer and a Searcher using Bitcask.
func (*Store) Get ¶ added in v0.4.2
Get is a wrapper for pogreb's Get function to regularize errors when keys do not exist.
func (*Store) PrefixScan ¶
PrefixScan will scan a Store for all keys that have a matching prefix of the given string and return a map of keys and values. (map[Key]Value) error channel will block, so be sure to read from it.
type WrappedOptions ¶
type WrappedOptions struct { *pogreb.Options `json:"options"` // AllowRecovery allows the database to be recovered if a lockfile is detected upon running Init. AllowRecovery bool `json:"allow_recovery,omitempty"` }
func (*WrappedOptions) MarshalJSON ¶ added in v0.4.2
func (w *WrappedOptions) MarshalJSON() ([]byte, error)