Back to godoc.org

Package stored

v0.5.0
Latest Go to latest
Published: Mar 27, 2020 | License: Apache-2.0 | Module: github.com/jthomperoo/predictive-horizontal-pod-autoscaler

Overview

Package stored provides interfacing methods for updating/retrieving data from the local sqlite3 database

Index

Package Files

type DBEvaluation

type DBEvaluation evaluate.Evaluation

DBEvaluation is an evaluation that can be stored in a SQL db, it is exactly the same as the evaluation but just with a Scan method implementation for marshalling from JSON

func (*DBEvaluation) Scan

func (d *DBEvaluation) Scan(src interface{}) error

Scan is used when reading the DBEvaluation field in from the SQL db, marshalling from a JSON string

type Evaluation

type Evaluation struct {
	ID         int          `db:"id"`
	Created    time.Time    `db:"created"`
	Evaluation DBEvaluation `db:"val"`
}

Evaluation is an evaluation stored in the database, with an ID and a timestamp

type LocalStore

type LocalStore struct {
	DB *sql.DB
}

LocalStore is the implementation of a Store for updating/retrieving evaluations from a SQL db

func (*LocalStore) AddEvaluation

func (s *LocalStore) AddEvaluation(model string, evaluation *evaluate.Evaluation) error

AddEvaluation inserts a new evaluation associated with a model

func (*LocalStore) GetEvaluation

func (s *LocalStore) GetEvaluation(model string) ([]*Evaluation, error)

GetEvaluation returns all evaluations associated with a model

func (*LocalStore) GetModel

func (s *LocalStore) GetModel(model string) (*Model, error)

GetModel gets the model with the name provided

func (*LocalStore) RemoveEvaluation

func (s *LocalStore) RemoveEvaluation(id int) error

RemoveEvaluation deletes an evaluation by the ID provided

func (*LocalStore) UpdateModel

func (s *LocalStore) UpdateModel(model string, intervalsPassed int) error

UpdateModel updates the model in the DB with the name provided, setting the intervals_passed value

type Model

type Model struct {
	ID              int    `db:"id"`
	Name            string `db:"model_name"`
	IntervalsPassed int    `db:"intervals_passed"`
}

Model is a model stored in the database, with an ID and the number of intervals since it was last used

type Storer

type Storer interface {
	GetEvaluation(model string) ([]*Evaluation, error)
	AddEvaluation(model string, evaluation *evaluate.Evaluation) error
	RemoveEvaluation(id int) error
	GetModel(model string) (*Model, error)
	UpdateModel(model string, intervalsPassed int) error
}

Storer allows updating/retrieving evaluations from a data source

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier