storage

package
v0.0.0-...-a7cb739 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package storage contains an implementation of interface between Go code and (almost any) SQL database like PostgreSQL, SQLite, or MariaDB. An implementation named DBStorage is constructed via New function and it is mandatory to call Close for any opened connection to database. The storage might be initialized by Init method if database schema is empty.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStorage

type MemoryStorage struct {
}

MemoryStorage data structure represents configuration of memory storage used to store mock data.

func New

func New(path string) (*MemoryStorage, error)

New function creates and initializes a new instance of Storage interface

func (MemoryStorage) Close

func (storage MemoryStorage) Close() error

Close method closes the connection to database. Needs to be called at the end of application lifecycle.

func (MemoryStorage) GetPredictionForCluster

func (storage MemoryStorage) GetPredictionForCluster(_ types.ClusterName) (*types.UpgradeRiskPrediction, error)

GetPredictionForCluster gets a prediction for the cluster

func (MemoryStorage) GetRuleWithContent

func (storage MemoryStorage) GetRuleWithContent(_ types.RuleID, _ types.ErrorKey) (*types.RuleWithContent, error)

GetRuleWithContent returns rule with content for provided ruleID and ruleErrorKey

func (MemoryStorage) Init

func (storage MemoryStorage) Init() error

Init performs all database initialization tasks necessary for further service operation.

func (MemoryStorage) ListOfClustersForOrg

func (storage MemoryStorage) ListOfClustersForOrg(orgID types.OrgID) ([]types.ClusterName, error)

ListOfClustersForOrg reads list of all clusters fro given organization

func (MemoryStorage) ListOfOrgs

func (storage MemoryStorage) ListOfOrgs() ([]types.OrgID, error)

ListOfOrgs reads list of all organizations that have at least one cluster report

func (MemoryStorage) ReadReportForCluster

func (storage MemoryStorage) ReadReportForCluster(
	clusterName types.ClusterName,
) (types.ClusterReport, error)

ReadReportForCluster reads result (health status) for selected cluster

func (MemoryStorage) ReadReportForOrganizationAndCluster

func (storage MemoryStorage) ReadReportForOrganizationAndCluster(
	orgID types.OrgID, clusterName types.ClusterName,
) (types.ClusterReport, error)

ReadReportForOrganizationAndCluster reads result (health status) for selected cluster for given organization

type Report

type Report struct {
	Org        types.OrgID         `json:"org"`
	Name       types.ClusterName   `json:"cluster"`
	Report     types.ClusterReport `json:"report"`
	ReportedAt types.Timestamp     `json:"reported_at"`
}

Report represents one (latest) cluster report.

Org: organization ID
Name: cluster GUID in the following format:
    c8590f31-e97e-4b85-b506-c45ce1911a12

type Storage

type Storage interface {
	Init() error
	Close() error
	ListOfOrgs() ([]types.OrgID, error)
	ListOfClustersForOrg(orgID types.OrgID) ([]types.ClusterName, error)
	ReadReportForCluster(clusterName types.ClusterName) (types.ClusterReport, error)
	ReadReportForOrganizationAndCluster(orgID types.OrgID, clusterName types.ClusterName) (types.ClusterReport, error)
	GetRuleWithContent(ruleID types.RuleID, ruleErrorKey types.ErrorKey) (*types.RuleWithContent, error)
	GetPredictionForCluster(cluster types.ClusterName) (*types.UpgradeRiskPrediction, error)
}

Storage represents an interface to almost any database or storage system

Jump to

Keyboard shortcuts

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