file

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package file provides a file-persisted stats collector. It wraps the in-memory collector and periodically (or on Flush) saves state to a gob-encoded file. On startup, the file is loaded to restore previous state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

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

Collector wraps memory.Collector with file persistence. It implements stats.Collector.

func New

func New(path string, opts ...Option) (*Collector, error)

New creates a file-persisted collector. The file is loaded on startup (if it exists) and saved on Flush/Close.

func (*Collector) Close

func (c *Collector) Close() error

Close flushes state and stops auto-flush.

func (*Collector) Counter

func (c *Collector) Counter(key string) stats.Counter

Counter delegates to the inner memory collector.

func (*Collector) Flush

func (c *Collector) Flush() error

Flush persists state to file.

func (*Collector) Gauge

func (c *Collector) Gauge(key string) stats.Gauge

Gauge delegates to the inner memory collector.

func (*Collector) HLL

func (c *Collector) HLL(key string) stats.HLL

HLL delegates to the inner memory collector.

func (*Collector) Set

func (c *Collector) Set(key string) stats.Set

Set delegates to the inner memory collector.

func (*Collector) Timer

func (c *Collector) Timer(key string) stats.Timer

Timer delegates to the inner memory collector.

type Option

type Option func(*Collector)

Option configures the file collector.

func WithAutoFlush

func WithAutoFlush(interval time.Duration) Option

WithAutoFlush enables periodic auto-flush at the given interval.

Jump to

Keyboard shortcuts

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