store

package
v0.0.0-...-8f9ebe2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const ANO_PREFIX = "a"
View Source
const HIS_METRIC_PREFIX = "hm"
View Source
const NO_EXPIRE int64 = -1
View Source
const REC_METRIC_PREFIX = "rm"

Variables

This section is empty.

Functions

func AddRecentMetrics

func AddRecentMetrics(name string, val *model.RecentMetrics) error

This method takes care of

func GetAnomaly

func GetAnomaly(name string) (*model.Anomaly, error)

func GetHistoricMetric

func GetHistoricMetric(name string, t time.Time, anom *model.Anomaly) (*model.Metric, error)

func GetRecentMetrics

func GetRecentMetrics(name string) (*model.RecentMetrics, error)

func InitStore

func InitStore(s KVStore)

InitStore to initialize store.

func StoreHistoricMetric

func StoreHistoricMetric(name string, m *model.Metric, anom *model.Anomaly) error

StoreHistoricMetric used to store the metric detaiks into a table TODO: Store in DB.

func UpsertAnomay

func UpsertAnomay(anom *model.Anomaly) error

Types

type KVStore

type KVStore interface {
	Set(key string, val []byte) error
	Get(key string) ([]byte, error)

	ExpirableSet(key string, val []byte, expireAt time.Time) error
	ExpirableGet(key string) ([]byte, error)
	// will call the corresponding method to expire the record if store is not
	// supporting expiry feature. Otherwise Noop.
	Cleanup() error
}

KVStore is an interface which is used to store/fetch the values

func GetStore

func GetStore() KVStore

GetStore to get the store which will be used for operations.

type SQLite

type SQLite struct {
	FilePath string `json:"file_path"`
	// contains filtered or unexported fields
}

SQLite data store config

func NewSQLite

func NewSQLite(file string) (*SQLite, error)

NewSQLite is used to get new instance of SQLite db

func (*SQLite) Cleanup

func (s *SQLite) Cleanup() error

Cleanup is to delete all the values which are expired from store. Implement only if necessary

func (*SQLite) ExpirableGet

func (s *SQLite) ExpirableGet(key string) ([]byte, error)

ExpirableGet - to get the value from expirable store

func (*SQLite) ExpirableSet

func (s *SQLite) ExpirableSet(key string, val []byte, t time.Time) error

ExpirableSet used to store the value with expiry time

func (*SQLite) Get

func (s *SQLite) Get(key string) ([]byte, error)

Get - to get the value from store.

func (*SQLite) Set

func (s *SQLite) Set(key string, val []byte) error

Set used to store the value

Jump to

Keyboard shortcuts

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