db

package
v0.38.262 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCheckStatusRetentionDays        = 60
	RetentionDaysFor1hCheckStatusAggregate = 180
	RetentionDaysFor1dCheckStatusAggregate = 1000
)

Variables

View Source
var CheckStatusRetentionDays int
View Source
var ConnectionString string
View Source
var DefaultExpiryDays int
View Source
var Gorm *gorm.DB
View Source
var HTTPEndpoint = "http://localhost:8080/db"
View Source
var PostgRESTServerPort = 3000
View Source
var PostgRESTVersion = "v9.0.0"
View Source
var RunMigrations bool

Functions

func AggregateCheckStatuses1d added in v0.38.246

func AggregateCheckStatuses1d()

AggregateCheckStatuses aggregates check statuses daily and stores it to the corresponding tables.

func AggregateCheckStatuses1h added in v0.38.246

func AggregateCheckStatuses1h()

AggregateCheckStatuses aggregates check statuses hourly and stores it to the corresponding tables.

func Cleanup

func Cleanup()

func ConvertNamedParams added in v0.38.85

func ConvertNamedParams(sql string, namedArgs map[string]interface{}) (string, []interface{})

func CreateCanary added in v0.38.85

func CreateCanary(canary *pkg.Canary) error

func CreateCheck added in v0.38.85

func CreateCheck(canary pkg.Canary, check *pkg.Check) error

func CreateComponentCanaryFromInline added in v0.38.151

func CreateComponentCanaryFromInline(id, name, namespace, schedule, owner string, spec *v1.CanarySpec) (*pkg.Canary, error)

func DeleteAllOldCheckStatuses added in v0.38.246

func DeleteAllOldCheckStatuses()

DeleteAllOldCheckStatuses deletes check statuses older than the configured retention period from 3 different tables.

func DeleteCanary added in v0.38.85

func DeleteCanary(canary v1.Canary) error

func DeleteCheckComponentRelationshipsForCanary added in v0.38.151

func DeleteCheckComponentRelationshipsForCanary(id string, deleteTime time.Time) error

func DeleteChecks added in v0.38.160

func DeleteChecks(id []string) error

func DeleteChecksForCanary added in v0.38.151

func DeleteChecksForCanary(id string, deleteTime time.Time) error

func DeleteComponentChildren added in v0.38.210

func DeleteComponentChildren(componentID string, deleteTime time.Time) error

func DeleteComponentRelationship added in v0.38.140

func DeleteComponentRelationship(componentID string, deleteTime time.Time) error

func DeleteComponentsWithIDs added in v0.38.125

func DeleteComponentsWithIDs(compIDs []string, deleteTime time.Time) error

DeleteComponentsWithID deletes all components with specified ids.

func DeleteComponentsWithSystemTemplate added in v0.38.210

func DeleteComponentsWithSystemTemplate(systemTemplateID string, deleteTime time.Time) error

DeleteComponents deletes all components associated with a systemTemplate

func DeleteConfigRelationshipForComponent added in v0.38.165

func DeleteConfigRelationshipForComponent(componentID uuid.UUID, deleteTime time.Time) error

func DeleteInlineCanariesForComponent added in v0.38.151

func DeleteInlineCanariesForComponent(componentID string, deleteTime time.Time) error

func DeleteSystemTemplate added in v0.38.106

func DeleteSystemTemplate(systemTemplate *v1.SystemTemplate) error

func FindCanary added in v0.38.85

func FindCanary(namespace, name string) (*pkg.Canary, error)

func FindCanaryByID added in v0.38.257

func FindCanaryByID(id string) (*pkg.Canary, error)

func FindCheck added in v0.38.85

func FindCheck(canary pkg.Canary, name string) (*pkg.Check, error)

func FindConfig added in v0.38.165

func FindConfig(config pkg.Config) (*pkg.Config, error)

func FindConfigForComponent added in v0.38.195

func FindConfigForComponent(componentID, configType string) ([]pkg.Config, error)

func GetActiveComponentsIDsWithSystemTemplateID added in v0.38.135

func GetActiveComponentsIDsWithSystemTemplateID(systemID string) (compIDs []uuid.UUID, err error)

func GetAllActiveChecksForCanary added in v0.38.160

func GetAllActiveChecksForCanary(canaryID uuid.UUID) (checks pkg.Checks, err error)

returns all the checks associated with canary which are currently executing

func GetAllCanaries added in v0.38.85

func GetAllCanaries() ([]v1.Canary, error)

func GetAllChecks added in v0.38.85

func GetAllChecks() ([]pkg.Check, error)

func GetAllChecksForCanary added in v0.38.151

func GetAllChecksForCanary(canaryID uuid.UUID) (checks pkg.Checks, err error)

returns all the checks associated with canary.

func GetAllComponentWithCanaries added in v0.38.151

func GetAllComponentWithCanaries() (components pkg.Components, err error)

func GetAllComponentsWithConfigs added in v0.38.172

func GetAllComponentsWithConfigs() (components pkg.Components, err error)

func GetAllComponentsWithSelectors added in v0.38.198

func GetAllComponentsWithSelectors() (components pkg.Components, err error)

Get all the components from table which has not null selectors

func GetAllSystemTemplates added in v0.38.106

func GetAllSystemTemplates() ([]v1.SystemTemplate, error)

func GetCanary added in v0.38.85

func GetCanary(id string) (*pkg.Canary, error)

func GetCheck added in v0.38.85

func GetCheck(id string) (*pkg.Check, error)

func GetCheckRelationshipsForComponent added in v0.38.181

func GetCheckRelationshipsForComponent(componentID uuid.UUID) ([]pkg.CheckComponentRelationship, error)

func GetChecksWithLabelSelector added in v0.38.151

func GetChecksWithLabelSelector(labelSelector string) (selectedChecks pkg.Checks, err error)

func GetChildRelationshipsForParentComponent added in v0.38.181

func GetChildRelationshipsForParentComponent(componentID uuid.UUID) ([]pkg.ComponentRelationship, error)

func GetComponentsWithFieldSelector added in v0.38.198

func GetComponentsWithFieldSelector(fieldSelector string) (components pkg.Components, err error)

func GetComponentsWithLabelSelector added in v0.38.198

func GetComponentsWithLabelSelector(labelSelector string) (components pkg.Components, err error)

func GetComponentsWithSelectors added in v0.38.151

func GetComponentsWithSelectors(resourceSelectors v1.ResourceSelectors) (components pkg.Components, err error)

func GetDB

func GetDB() (*sql.DB, error)

func GetLabelsFromSelector added in v0.38.114

func GetLabelsFromSelector(selector string) (matchLabels map[string]string)

func GetSystemTemplate added in v0.38.257

func GetSystemTemplate(ctx context.Context, id string) (*v1.SystemTemplate, error)

func GetTransformedCheckIDs added in v0.38.260

func GetTransformedCheckIDs(canaryID string) ([]string, error)

func GoOffline added in v0.38.149

func GoOffline() error

func Init

func Init() error

func IsConfigured added in v0.38.85

func IsConfigured() bool

func IsConnected added in v0.38.85

func IsConnected() bool

func NewComponentRelationships added in v0.38.181

func NewComponentRelationships(relationshipID uuid.UUID, path string, components pkg.Components) (relationships []*pkg.ComponentRelationship, err error)

func PersistCanary added in v0.38.85

func PersistCanary(canary v1.Canary, source string) (*pkg.Canary, map[string]string, bool, error)

func PersistCheck added in v0.38.85

func PersistCheck(check pkg.Check, canaryID uuid.UUID) (uuid.UUID, error)

func PersistCheckComponentRelationship added in v0.38.151

func PersistCheckComponentRelationship(relationship *pkg.CheckComponentRelationship) error

func PersistComponent added in v0.38.85

func PersistComponent(component *pkg.Component) ([]uuid.UUID, error)

TODO: Simplify logic and improve readability

func PersistComponentRelationship added in v0.38.114

func PersistComponentRelationship(relationship *pkg.ComponentRelationship) error

func PersistComponents added in v0.38.135

func PersistComponents(results []*pkg.Component) error

func PersistConfigComponentRelationship added in v0.38.165

func PersistConfigComponentRelationship(configID, componentID uuid.UUID, selectorID string) error

func PersistJobHistory added in v0.38.201

func PersistJobHistory(h *models.JobHistory) error

func PersistSystemTemplate added in v0.38.106

func PersistSystemTemplate(system *v1.SystemTemplate) (string, bool, error)

func PostgRESTEndpoint added in v0.38.137

func PostgRESTEndpoint() string

func QueryNamed added in v0.38.85

func QueryNamed(ctx context.Context, sql string, args map[string]interface{}) (pgx.Rows, error)

TODO: Use pgx/v5 and use Pool.Query(ctx, sql, pgx.NamedArgs{})

func RefreshCheckStatusSummary added in v0.38.232

func RefreshCheckStatusSummary()

func Start added in v0.38.85

func Start(ctx context.Context) error

func StartPostgrest added in v0.38.137

func StartPostgrest()

func StopServer added in v0.38.83

func StopServer() error

func UpdateChecksStatus added in v0.38.260

func UpdateChecksStatus(ids []string, status models.CheckHealthStatus) error

func UpdateComponentCosts added in v0.38.199

func UpdateComponentCosts() error

func UpdateStatusAndSummaryForComponent added in v0.38.146

func UpdateStatusAndSummaryForComponent(id uuid.UUID, status models.ComponentStatus, summary models.Summary) (int64, error)

Types

type ConfigComponentRelationship added in v0.38.176

type ConfigComponentRelationship struct {
	ComponentID uuid.UUID
	ConfigID    uuid.UUID
	SelectorID  string
	DeletedAt   *time.Time
}

Store entry in config_component_relationship table

func GetConfigRelationshipsForComponent added in v0.38.165

func GetConfigRelationshipsForComponent(componentID uuid.UUID) ([]ConfigComponentRelationship, error)

Directories

Path Synopsis
nolint
nolint

Jump to

Keyboard shortcuts

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