Re-enable primary-store healtcheck

This commit is contained in:
Denis Arh
2022-09-14 12:18:43 +02:00
parent 9e6241a610
commit 8ff4015192
11 changed files with 30 additions and 9 deletions
+2
View File
@@ -217,6 +217,8 @@ func (app *CortezaApp) InitStore(ctx context.Context) (err error) {
if err = store.Upgrade(ctx, log, app.Store); err != nil {
return fmt.Errorf("could not upgrade primary store: %w", err)
}
healthcheck.Defaults().Add(app.Store.Healthcheck, "Primary store")
}
{
@@ -42,6 +42,8 @@ type (
// Upgrade store's schema to the latest version
Upgrade(context.Context) error
Healthcheck(context.Context) error
{{- range .types }}
{{ .expIdentPlural }}
{{- end }}
+1
View File
@@ -81,6 +81,7 @@ _StoreResource: {
}
deleteByPK: {
"pkAttrNames": pkAttrNames,
attributes: [ for attr in pkAttrNames { res.model.attributes[attr] } ]
_expIdents: strings.Join([ for attr in pkAttrNames { res.model.attributes[attr].expIdent } ], "")
"expFnIdent": "Delete\(res.store.expIdent)By\(_expIdents)"
@@ -52,6 +52,7 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
ErrorHandler: errorHandler,
DataDefiner: DataDefiner(cfg.DBName, db),
Ping: db.PingContext,
}
s.SetDefaults()
@@ -56,6 +56,7 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
ErrorHandler: errorHandler,
DataDefiner: DataDefiner(cfg.DBName, db),
Ping: db.PingContext,
}
s.SetDefaults()
@@ -77,6 +77,8 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
TxRetryLimit: -1,
DataDefiner: DataDefiner(cfg.DBName, db),
Ping: db.PingContext,
}
s.SetDefaults()
+2 -2
View File
@@ -17590,10 +17590,10 @@ func (s *Store) DeleteSettingValue(ctx context.Context, rr ...*systemType.Settin
// DeleteSettingValueByID deletes single entry from settingValue collection
//
// This function is auto-generated
func (s *Store) DeleteSettingValueByNameOwnedBy(ctx context.Context, name string, ownedBy uint64) error {
func (s *Store) DeleteSettingValueByOwnedByName(ctx context.Context, ownedBy uint64, name string) error {
return s.Exec(ctx, settingValueDeleteQuery(s.Dialect, goqu.Ex{
"name": name,
"rel_owner": ownedBy,
"name": name,
}))
}
+11
View File
@@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"github.com/cortezaproject/corteza-server/pkg/dal"
"github.com/cortezaproject/corteza-server/pkg/errors"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/store/adapters/rdbms/ddl"
"github.com/doug-martin/goqu/v9"
@@ -65,6 +66,8 @@ type (
// additional (per-resource-type) filters used when searching
// these filters can modify expression used for querying the database
Filters *extendedFilters
Ping func(ctx context.Context) error
}
)
@@ -102,6 +105,14 @@ func (s *Store) withTx(tx sqlx.ExtContext) *Store {
}
}
func (s Store) Healthcheck(ctx context.Context) error {
if s.Ping == nil {
return errors.Internal("no store ping function defined")
}
return s.Ping(ctx)
}
func (s Store) Exec(ctx context.Context, q sqlizer) error {
var (
query, args, err = q.ToSQL()
+5 -3
View File
@@ -42,6 +42,8 @@ type (
// Upgrade store's schema to the latest version
Upgrade(context.Context) error
Healthcheck(context.Context) error
Actionlogs
ApigwFilters
ApigwRoutes
@@ -554,7 +556,7 @@ type (
UpdateSettingValue(ctx context.Context, rr ...*systemType.SettingValue) error
UpsertSettingValue(ctx context.Context, rr ...*systemType.SettingValue) error
DeleteSettingValue(ctx context.Context, rr ...*systemType.SettingValue) error
DeleteSettingValueByNameOwnedBy(ctx context.Context, name string, ownedBy uint64) error
DeleteSettingValueByOwnedByName(ctx context.Context, ownedBy uint64, name string) error
TruncateSettingValues(ctx context.Context) error
LookupSettingValueByNameOwnedBy(ctx context.Context, name string, ownedBy uint64) (*systemType.SettingValue, error)
}
@@ -3102,8 +3104,8 @@ func DeleteSettingValue(ctx context.Context, s SettingValues, rr ...*systemType.
// DeleteSettingValueByID deletes one or more SettingValues from store
//
// This function is auto-generated
func DeleteSettingValueByNameOwnedBy(ctx context.Context, s SettingValues, name string, ownedBy uint64) error {
return s.DeleteSettingValueByNameOwnedBy(ctx, name, ownedBy)
func DeleteSettingValueByOwnedByName(ctx context.Context, s SettingValues, ownedBy uint64, name string) error {
return s.DeleteSettingValueByOwnedByName(ctx, ownedBy, name)
}
// TruncateSettingValues Deletes all SettingValues from store
+2 -3
View File
@@ -2210,9 +2210,8 @@ var SettingValue = &dal.Model{
Indexes: dal.IndexSet{
&dal.Index{
Ident: "settings_uniqueKindResName",
Type: "BTREE",
Unique: true,
Ident: "PRIMARY",
Type: "BTREE",
Fields: []*dal.IndexField{
{
+1 -1
View File
@@ -36,7 +36,7 @@ settings: {
}
indexes: {
"unique_kind_res_name": {
"primary": {
fields: [
{ attribute: "owned_by" },
{ attribute: "name", modifiers: [ "LOWERCASE" ] },