stats

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package stats defines a stats provider service, wrapping a cache & stats component calculation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCacheMiss indicates a requested path isn't in the cache
	ErrCacheMiss = fmt.Errorf("stats: cache miss")
	// ErrNoCache indicates there is no cache
	ErrNoCache = fmt.Errorf("stats: no cache")
	// ErrCacheCorrupt indicates a faulty stats cache
	ErrCacheCorrupt = fmt.Errorf("stats: cache is corrupt")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// placing a stats object in the Cache will expire all caches with a lower
	// modTime, use a modTime of zero when no modTime is known
	PutStats(ctx context.Context, key string, sa *dataset.Stats) error
	// GetStats the stats component for a given key
	GetStats(ctx context.Context, key string) (sa *dataset.Stats, err error)
}

Cache is a store of stats components Consumers of a cache must not rely on the cache for persistence Implementations are expected to maintain their own size bounding semantics internally Cache implementations must be safe for concurrent use, and must be nil-callable

func NewLocalCache added in v0.10.0

func NewLocalCache(rootDir string, maxSize int64) (Cache, error)

NewLocalCache creates a cache in a local directory. LocalCache is sensitive to added keys that match the qfs.PathKind of "local". When a stats component is added with a local filepath as it's key, LocalCache will record the status of that file, and return ErrCacheMiss if that filepath is altered on retrieval

type Props added in v0.10.0

type Props = didmod.Props

Props is an alias of

type Service added in v0.10.0

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

Service can generate an array of statistical info for a dataset

func New

func New(cache Cache) *Service

New allocates a Stats service

func (*Service) Stats added in v0.10.0

func (s *Service) Stats(ctx context.Context, ds *dataset.Dataset) (*dataset.Stats, error)

Stats gets the stats component for a dataset, possibly calculating by consuming the open dataset body file

Jump to

Keyboard shortcuts

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