Documentation ¶
Overview ¶
Package localdb provides an implementation of filewalk.Database that uses a local key/value store currently based on github.com/recoilme/pudge.
Index ¶
- Variables
- func Open(ctx context.Context, dir string, ifcOpts []filewalk.DatabaseOption, ...) (filewalk.Database, error)
- type Database
- func (db *Database) Close(ctx context.Context) error
- func (db *Database) CompactAndClose(ctx context.Context) error
- func (db *Database) Delete(ctx context.Context, separator string, prefixes []string, recurse bool) (int, error)
- func (db *Database) DeleteErrors(ctx context.Context, prefixes []string) (int, error)
- func (db *Database) Get(ctx context.Context, prefix string, info *filewalk.PrefixInfo) (bool, error)
- func (db *Database) GroupIDs(ctx context.Context) ([]string, error)
- func (db *Database) Metrics() []filewalk.MetricName
- func (db *Database) NewScanner(prefix string, limit int, opts ...filewalk.ScannerOption) filewalk.DatabaseScanner
- func (db *Database) Save(ctx context.Context) error
- func (db *Database) Set(ctx context.Context, prefix string, info *filewalk.PrefixInfo) error
- func (db *Database) Stats() ([]filewalk.DatabaseStats, error)
- func (db *Database) TopN(ctx context.Context, name filewalk.MetricName, n int, ...) ([]filewalk.Metric, error)
- func (db *Database) Total(ctx context.Context, name filewalk.MetricName, opts ...filewalk.MetricOption) (int64, error)
- func (db *Database) UserIDs(ctx context.Context) ([]string, error)
- type DatabaseOption
- type ScanOption
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var ErrReadonly = errors.New("database is opened in readonly mode")
ErrReadonly is returned if an attempt is made to write to a database opened in read-only mode.
Functions ¶
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents an on-disk database that stores information and statistics for filesystem directories/prefixes. The database supports read-write and read-only modes of access.
func (*Database) DeleteErrors ¶
func (*Database) Metrics ¶
func (db *Database) Metrics() []filewalk.MetricName
func (*Database) NewScanner ¶
func (db *Database) NewScanner(prefix string, limit int, opts ...filewalk.ScannerOption) filewalk.DatabaseScanner
type DatabaseOption ¶
type DatabaseOption func(o *Database)
DatabaseOption represents a specific option accepted by Open.
func LockStatusDelay ¶
func LockStatusDelay(d time.Duration) DatabaseOption
LockStatusDelay sets the delay between checking the status of acquiring a lock on the database.
func SyncInterval ¶
func SyncInterval(interval time.Duration) DatabaseOption
SyncInterval set the interval at which the database is to be persisted to disk.
func TryLock ¶
func TryLock() DatabaseOption
TryLock returns an error if the database cannot be locked within the delay period.
type ScanOption ¶
type ScanOption func(ks *Scanner)
ScanOption represents an option used when creating a Scanner.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner allows for the contents of an instance of Database to be enumerated. The database is organized as a key value store that can be scanned by range or by prefix.
func NewScanner ¶
func NewScanner(db *Database, prefix string, limit int, ifcOpts []filewalk.ScannerOption, opts ...ScanOption) *Scanner
NewScanner returns a new instance of Scanner.
func (*Scanner) PrefixInfo ¶
func (sc *Scanner) PrefixInfo() (string, *filewalk.PrefixInfo)
PrefixInfo implements filewalk.DatabaseScanner.