README
Package cloudeng.io/file/filewalk/localdb
import cloudeng.io/file/filewalk/localdb
Package localdb provides an implementation of filewalk.Database that uses a local key/value store currently based on github.com/recoilme/pudge.
Variables
ErrReadonly
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
Func Open
func Open(ctx context.Context, dir string, ifcOpts []filewalk.DatabaseOption, opts ...DatabaseOption) (filewalk.Database, error)
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.
Methods
func (db *Database) Close(ctx context.Context) 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) TopN(ctx context.Context, name filewalk.MetricName, n int, opts ...filewalk.MetricOption) ([]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 DatabaseOption func(o *Database)
DatabaseOption represents a specific option accepted by Open.
Functions
func LockStatusDelay(d time.Duration) DatabaseOption
LockStatusDelay sets the delay between checking the status of acquiring a lock on the database.
func SyncInterval(interval time.Duration) DatabaseOption
SyncInterval set the interval at which the database is to be persisted to disk.
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.
Functions
func NewScanner(db *Database, prefix string, limit int, ifcOpts []filewalk.ScannerOption, opts ...ScanOption) *Scanner
NewScanner returns a new instance of Scanner.
Methods
func (sc *Scanner) Err() error
Err rimplements filewalk.DatabaseScanner.
func (sc *Scanner) PrefixInfo() (string, *filewalk.PrefixInfo)
PrefixInfo implements filewalk.DatabaseScanner.
func (sc *Scanner) Scan(ctx context.Context) bool
Scan implements filewalk.DatabaseScanner.
TODO
- cnicolaou: build a lexicon of layout and user info to save space on disk.
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) 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) 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 ¶
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) 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.