storage

package
v0.0.0-...-d2219ce Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DUMMY_OUTBOUND_ADDR         = "8.8.8.8:80"             // Some outbound address for dummy requests.
	PROMETHEUS_JOB              = "cryptarch"              // What to apply for the Prometheus job.
	PROMETHEUS_METRICS_ENDPOINT = "/results"               // Endpoint where Prometheus metrics are presented.
	PROMETHEUS_METRICS_HELP     = "Produced by Cryptarch." // Help text for all Prometheus metrics.
	PROMETHEUS_METRIC_LABEL     = "cryptarch_label"        // What Prometheus label to use for the Cryptarch label.
	PROMETHEUS_METRIC_PREFIX    = "cryptarch"              // Prefix for all Prometheus metrics.
)
View Source
const (
	MAX_EXTERNAL_STORAGES  = 128            // Maximum external storage integrations.
	MAX_RESULTS            = 128            // Maximum number of result series that may be maintained.
	PUT_EVENT_CHANNEL_SIZE = 128            // Size of put channels, controlling the amount of waiting results.
	STORAGE_FILE_DIR       = "cryptarch"    // Directory in user cache to use for storage.
	STORAGE_FILE_NAME      = "storage.json" // Filename to use for actual storage.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgsRPC

type ArgsRPC struct{}

type NaNError

type NaNError struct {
	// Value attempted to be used
	Value interface{}
}

Error indicating a number is expected but was not provided.

func (*NaNError) Error

func (e *NaNError) Error() string

type PrometheusStorage

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

func NewPrometheusStorage

func NewPrometheusStorage(address string) PrometheusStorage

Create a new storage for Prometheus.

func (*PrometheusStorage) Put

func (p *PrometheusStorage) Put(query string, labels []string, result Result) error

Register a result in a Prometheus registry.

type PushgatewayStorage

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

Prometheus Pushgateway specific external storage system.

func NewPushgatewayStorage

func NewPushgatewayStorage(address string) PushgatewayStorage

Create a new storage for Pushgateway.

func (*PushgatewayStorage) Put

func (p *PushgatewayStorage) Put(query string, labels []string, result Result) error

Add a result to Prometheus Pushgtateway.

type ReaderIndex

type ReaderIndex int

Reader indexes control where a consumer has last read a result.

func (*ReaderIndex) Dec

func (i *ReaderIndex) Dec()

Decrement a reader index, to re-read the last read.

func (*ReaderIndex) Inc

func (i *ReaderIndex) Inc()

Incremement a reader index, likely after a read.

func (*ReaderIndex) Set

func (i *ReaderIndex) Set(newI int)

Sets a redaer index to a specified value.

type Result

type Result struct {
	Time   time.Time // Time the result was created.
	Value  string    // Raw value of the result.
	Values Values    // Tokenized value of the result.
}

Individual result.

func (*Result) IsEmpty

func (r *Result) IsEmpty() bool

Determines whether this is an empty result.

type Results

type Results struct {
	// Meta field for result values acting as a name, corresponding by index. In the event that no
	// explicit labels are defined, the indexes are the labels.
	Labels []string
	// Stored results.
	Results []Result
}

Collection of results.

func (*Results) GetAllRPC

func (r *Results) GetAllRPC(args *ArgsRPC, results *ResultsRPC) error

type ResultsRPC

type ResultsRPC struct {
	Results *Results
}

type Storage

type Storage struct {
	Results map[string]*Results // Map of queries to results.
	// contains filtered or unexported fields
}

Collection of results mapped to their queries.

func NewStorage

func NewStorage(persistence bool) (storage Storage, err error)

Initializes a new storage, loading in any saved storage data.

func (*Storage) AddExternalStorage

func (s *Storage) AddExternalStorage(e externalStorage)

Adds an external storage.

func (*Storage) Close

func (s *Storage) Close()

Closes a storage. Should be called after all storage operations cease.

func (*Storage) Get

func (s *Storage) Get(query string, time time.Time) Result

Get a result based on a timestamp.

func (*Storage) GetAll

func (s *Storage) GetAll(query string) []Result

Get all results.

func (*Storage) GetLabels

func (s *Storage) GetLabels(query string) []string

Get a result's labels.

func (*Storage) GetRange

func (s *Storage) GetRange(query string, startTime, endTime time.Time) []Result

Gets results based on a start and end timestamp.

func (*Storage) GetToIndex

func (s *Storage) GetToIndex(query string, index *ReaderIndex) []Result

Given results up to a reader index (a.k.a. "playback").

func (*Storage) GetValueIndex

func (s *Storage) GetValueIndex(query, filter string) int

Given a filter, return the corresponding value index.

func (*Storage) NewReaderIndex

func (s *Storage) NewReaderIndex(query string) *ReaderIndex

Initialize a new reader index. Will attempt to set the initial value to the end of existing results, if results already exist.

func (*Storage) Next

func (s *Storage) Next(query string, reader *ReaderIndex) (next Result)

Retrieve the next result from a put event channel, blocking if none exists.

func (*Storage) NextOrEmpty

func (s *Storage) NextOrEmpty(query string, reader *ReaderIndex) (next Result)

Retrieve the next result from a put event channel, returning an empty result if nothing exists.

func (*Storage) Put

func (s *Storage) Put(
	query, value string,
	persistence bool,
	values ...interface{},
) (result Result, err error)

Put a new result.

func (*Storage) PutLabels

func (s *Storage) PutLabels(query string, labels []string)

Assigns explicit labels to a results series.

func (*Storage) Show

func (s *Storage) Show(query string)

Show all currently stored results.

type Values

type Values []interface{}

Tokenized result value.

func (Values) Get

func (v Values) Get(index int) (result interface{})

Retrieve an indexed token.

Jump to

Keyboard shortcuts

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