disk

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package disk provides storage functionality.

Index

Constants

View Source
const (
	CostContentIdentifier          = "metrics"
	ObservabilityContentIdentifier = "observability"
)

Variables

This section is empty.

Functions

func NewParquetStreamer

func NewParquetStreamer(input io.Reader) io.ReadCloser

NewParquetStreamer reads a Brotli-compressed JSON file containing an array of Metrics, and returns a reader with the data transcoded to Snappy-compressed Parquet.

Types

type DiskStore

type DiskStore struct {
	// contains filtered or unexported fields
}

DiskStore is a data store intended to be backed by a disk. Currently, data is stored in Brotli-compressed JSON, but transcoded to Snappy-compressed Parquet

func NewDiskStore

func NewDiskStore(settings config.Database, opts ...DiskStoreOpt) (*DiskStore, error)

NewDiskStore initializes a DiskStore with a directory path and row limit

func (*DiskStore) All

func (d *DiskStore) All(ctx context.Context, file string) (types.MetricRange, error)

All retrieves all metrics from uncompacted .json.br files, excluding the active and compressed files. It reads the data into memory and returns a MetricRange.

func (*DiskStore) Flush

func (d *DiskStore) Flush() error

Flush finalizes the current writer, writes all buffered data to disk, and renames the file

func (*DiskStore) GetFiles

func (d *DiskStore) GetFiles(paths ...string) ([]string, error)

func (*DiskStore) GetUsage

func (d *DiskStore) GetUsage(limit uint64, paths ...string) (*types.StoreUsage, error)

GetUsage gathers disk usage stats using syscall.Statfs. paths will be used as `filepath.Join(paths...)`

func (*DiskStore) ListFiles

func (d *DiskStore) ListFiles(paths ...string) ([]os.DirEntry, error)

func (*DiskStore) MaxInterval

func (d *DiskStore) MaxInterval() time.Duration

func (*DiskStore) Pending

func (d *DiskStore) Pending() int

Pending returns the count of buffered rows not yet written to disk

func (*DiskStore) Put

func (d *DiskStore) Put(ctx context.Context, metrics ...types.Metric) error

Put appends metrics to the JSON file, creating a new file if the row limit is reached

func (*DiskStore) Walk

func (d *DiskStore) Walk(loc string, process filepath.WalkFunc) error

Walk will run `process` to walk the file tree

type DiskStoreOpt

type DiskStoreOpt = func(d *DiskStore) error

func WithContentIdentifier

func WithContentIdentifier(identifier string) DiskStoreOpt

func WithMaxInterval

func WithMaxInterval(interval time.Duration) DiskStoreOpt

type MetricFile

type MetricFile struct {
	*os.File // wrapper around an os.File
	// contains filtered or unexported fields
}

func NewMetricFile

func NewMetricFile(path string) (*MetricFile, error)

func (*MetricFile) Close

func (f *MetricFile) Close() error

func (*MetricFile) Location

func (f *MetricFile) Location() (string, error)

func (*MetricFile) Read

func (f *MetricFile) Read(p []byte) (int, error)

func (*MetricFile) Rename

func (f *MetricFile) Rename(new string) error

func (*MetricFile) Size

func (f *MetricFile) Size() (int64, error)

Size returns the size of the file.

func (*MetricFile) UniqueID

func (f *MetricFile) UniqueID() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL