storage

package
v0.0.0-...-7c0796b Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBStorage

type DBStorage struct {
	DBConnection *sql.DB
}

func NewDBStorage

func NewDBStorage(dsn string) *DBStorage

func (*DBStorage) AddCounter

func (strg *DBStorage) AddCounter(ctx context.Context, key string, value int64)

func (*DBStorage) Clear

func (strg *DBStorage) Clear()

func (*DBStorage) CloseDB

func (strg *DBStorage) CloseDB() error

func (*DBStorage) GetAllCounters

func (strg *DBStorage) GetAllCounters(ctx context.Context) map[string]int64

func (*DBStorage) GetAllGauges

func (strg *DBStorage) GetAllGauges(ctx context.Context) map[string]float64

func (*DBStorage) GetCounter

func (strg *DBStorage) GetCounter(ctx context.Context, name string) (int64, error)

func (*DBStorage) GetCounterOrZero

func (strg *DBStorage) GetCounterOrZero(ctx context.Context, name string) int64

func (*DBStorage) GetDB

func (strg *DBStorage) GetDB() *DBStorage

func (*DBStorage) GetGauge

func (strg *DBStorage) GetGauge(ctx context.Context, name string) (float64, error)

func (*DBStorage) GetGaugeOrZero

func (strg *DBStorage) GetGaugeOrZero(ctx context.Context, name string) float64

func (*DBStorage) GetMemStorage

func (strg *DBStorage) GetMemStorage() *MemStorage

func (*DBStorage) LoadFromDisk

func (strg *DBStorage) LoadFromDisk(_ context.Context, _ string) (err error)

func (*DBStorage) SaveToDisk

func (strg *DBStorage) SaveToDisk(ctx context.Context, filename string) (err error)

func (*DBStorage) SetGauge

func (strg *DBStorage) SetGauge(ctx context.Context, key string, value float64)

type Interface

type Interface interface {
	Clear()

	AddCounter(ctx context.Context, key string, value int64)
	SetGauge(ctx context.Context, key string, value float64)

	GetGauge(ctx context.Context, name string) (float64, error)
	GetCounter(ctx context.Context, name string) (int64, error)
	GetGaugeOrZero(ctx context.Context, name string) float64
	GetCounterOrZero(ctx context.Context, name string) int64
	GetAllGauges(ctx context.Context) map[string]float64
	GetAllCounters(ctx context.Context) map[string]int64

	SaveToDisk(ctx context.Context, filename string) (err error)
	LoadFromDisk(ctx context.Context, filename string) (err error)

	GetDB() *DBStorage
	GetMemStorage() *MemStorage

	CloseDB() error
}

func New

func New(dsn string) Interface

type MemStorage

type MemStorage struct {
	Counters map[string]int64   `json:"counters"`
	Gauges   map[string]float64 `json:"gauges"`
	// contains filtered or unexported fields
}

func NewRAMStorage

func NewRAMStorage() *MemStorage

func (*MemStorage) AddCounter

func (strg *MemStorage) AddCounter(_ context.Context, key string, value int64)

func (*MemStorage) Clear

func (strg *MemStorage) Clear()

func (*MemStorage) CloseDB

func (strg *MemStorage) CloseDB() error

func (*MemStorage) GetAllCounters

func (strg *MemStorage) GetAllCounters(_ context.Context) map[string]int64

func (*MemStorage) GetAllGauges

func (strg *MemStorage) GetAllGauges(_ context.Context) map[string]float64

func (*MemStorage) GetCounter

func (strg *MemStorage) GetCounter(ctx context.Context, name string) (int64, error)

func (*MemStorage) GetCounterOrZero

func (strg *MemStorage) GetCounterOrZero(_ context.Context, name string) int64

func (*MemStorage) GetDB

func (strg *MemStorage) GetDB() *DBStorage

func (*MemStorage) GetGauge

func (strg *MemStorage) GetGauge(ctx context.Context, name string) (float64, error)

func (*MemStorage) GetGaugeOrZero

func (strg *MemStorage) GetGaugeOrZero(_ context.Context, name string) float64

func (*MemStorage) GetMemStorage

func (strg *MemStorage) GetMemStorage() *MemStorage

func (*MemStorage) LoadFromDisk

func (strg *MemStorage) LoadFromDisk(_ context.Context, filename string) (err error)

func (*MemStorage) SaveToDisk

func (strg *MemStorage) SaveToDisk(_ context.Context, filename string) (err error)

func (*MemStorage) SetGauge

func (strg *MemStorage) SetGauge(_ context.Context, key string, value float64)

type SavedOnDisc

type SavedOnDisc struct {
	Counters map[string]int64   `json:"counters"`
	Gauges   map[string]float64 `json:"gauges"`
}

Jump to

Keyboard shortcuts

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