README

Package cloudeng.io/file/filewalk/localdb

CircleCI Go Report Card

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.
Expand ▾ Collapse ▴

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

Constants

This section is empty.

Variables

View Source
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

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.

func (*Database) Close

func (db *Database) Close(ctx context.Context) error

func (*Database) Get

func (db *Database) Get(ctx context.Context, prefix string, info *filewalk.PrefixInfo) (bool, error)

func (*Database) GroupIDs

func (db *Database) GroupIDs(ctx context.Context) ([]string, error)

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

func (*Database) Save

func (db *Database) Save(ctx context.Context) error

func (*Database) Set

func (db *Database) Set(ctx context.Context, prefix string, info *filewalk.PrefixInfo) error

func (*Database) TopN

func (db *Database) TopN(ctx context.Context, name filewalk.MetricName, n int, opts ...filewalk.MetricOption) ([]filewalk.Metric, error)

func (*Database) Total

func (db *Database) Total(ctx context.Context, name filewalk.MetricName, opts ...filewalk.MetricOption) (int64, error)

func (*Database) UserIDs

func (db *Database) UserIDs(ctx context.Context) ([]string, error)

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) Err

func (sc *Scanner) Err() error

Err rimplements filewalk.DatabaseScanner.

func (*Scanner) PrefixInfo

func (sc *Scanner) PrefixInfo() (string, *filewalk.PrefixInfo)

PrefixInfo implements filewalk.DatabaseScanner.

func (*Scanner) Scan

func (sc *Scanner) Scan(ctx context.Context) bool

Scan implements filewalk.DatabaseScanner.