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 ¶
- type MemoryStorage
- func (storage MemoryStorage) Close() error
- func (storage MemoryStorage) GetPredictionForCluster(_ types.ClusterName) (*types.UpgradeRiskPrediction, error)
- func (storage MemoryStorage) GetRuleWithContent(_ types.RuleID, _ types.ErrorKey) (*types.RuleWithContent, error)
- func (storage MemoryStorage) Init() error
- func (storage MemoryStorage) ListOfClustersForOrg(orgID types.OrgID) ([]types.ClusterName, error)
- func (storage MemoryStorage) ListOfOrgs() ([]types.OrgID, error)
- func (storage MemoryStorage) ReadReportForCluster(clusterName types.ClusterName) (types.ClusterReport, error)
- func (storage MemoryStorage) ReadReportForOrganizationAndCluster(orgID types.OrgID, clusterName types.ClusterName) (types.ClusterReport, error)
- type Report
- type Storage
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