Documentation ¶
Overview ¶
package files implements a disk.Source and disk.Writer
Index ¶
- Variables
- type DB
- func (db *DB) Metrics(ctx context.Context, cb func(name string) (bool, error)) (err error)
- func (db *DB) PopulateMetrics(ctx context.Context) (err error)
- func (db *DB) Query(ctx context.Context, metric string, end int64, buf []byte, ...) error
- func (db *DB) QueryLatest(ctx context.Context, metric string, buf []byte) (start, end int64, data []byte, err error)
- func (db *DB) Queue(ctx context.Context, metric string, start int64, end int64, data []byte, ...) (err error)
- func (db *DB) Run(ctx context.Context) error
- type Options
- type Tuning
Constants ¶
This section is empty.
Variables ¶
var Error = errs.Class("files")
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a database implementing database.Sink and database.Source using a file on disk for each metric.
func (*DB) PopulateMetrics ¶
PopulateMetrics walks the directory tree of the metrics recreating the in-memory cache of metric names. It should be called periodically.
func (*DB) Query ¶
func (db *DB) Query(ctx context.Context, metric string, end int64, buf []byte, cb database.ResultCallback) error
Query calls the ResultCallback with all of the data slices that end strictly before the provided end time in strictly decreasing order by their end. It will continue to call the ResultCallback until it exhausts all of the records, or the callback returns false.
func (*DB) QueryLatest ¶
func (db *DB) QueryLatest(ctx context.Context, metric string, buf []byte) ( start, end int64, data []byte, err error)
QueryLatest returns the latest value stored for the metric. buf is used as storage for the data slice if possible.
func (*DB) Queue ¶
func (db *DB) Queue(ctx context.Context, metric string, start int64, end int64, data []byte, cb func(bool, error)) (err error)
Queue adds the data for the metric and the given start and end times. If the start time is before the last end time for the metric, no write will happen. The callback is called with the error value of writing the metric.
type Options ¶
type Options struct { Size int // size of each record Cap int // cap of the number of records per file Files int // the number of historical files per metric Tuning Tuning // tuning parameters }
Options is a set of options to configure a database.
type Tuning ¶
type Tuning struct { // Buffer controls the number of records that can be queued for writing. Buffer int // Drop, when true, will cause queued records to be discarded if the // buffer is full. Drop bool // Handles controls the number of open file handles for metrics in the // cache. If 0, then 1024 less than the soft limit of file handles as // reported by getrlimit will be used. Handles int // Workers controls the number of parallel workers draining queued values // into files. If zero, one less than GOMAXPROCS worker is used. // // The number of workers should be less than GOMAXPROCS, because each // worker deals with memory mapped files. The go runtime will not be able // to schedule around goroutines blocked on page faults, which could cause // goroutines to starve. Workers int }
Tuning controls some tuning details of the database.