DualWriter: Minor cleanup (#107028)
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
package dualwrite
|
||||
|
||||
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
|
||||
// Not yet used... but you get the idea
|
||||
func AddUnifiedStatusMigrations(mg *migrator.Migrator) {
|
||||
resourceStorageStatus := migrator.Table{
|
||||
Name: "resource_storage_status",
|
||||
Columns: []*migrator.Column{
|
||||
{Name: "group", Type: migrator.DB_NVarchar, Length: 190, Nullable: false},
|
||||
{Name: "resource", Type: migrator.DB_NVarchar, Length: 190, Nullable: false},
|
||||
{Name: "write_legacy", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"},
|
||||
{Name: "write_unified", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"},
|
||||
{Name: "read_unified", Type: migrator.DB_Bool, Nullable: false},
|
||||
{Name: "migrating", Type: migrator.DB_BigInt, Nullable: false}, // Timestamp Actively running a migration (start timestamp)
|
||||
{Name: "migrated", Type: migrator.DB_BigInt, Nullable: false}, // Timestamp job finished
|
||||
{Name: "runtime", Type: migrator.DB_Bool, Nullable: false, Default: "TRUE"},
|
||||
{Name: "update_key", Type: migrator.DB_BigInt, Nullable: false}, // optimistic lock key -- required for update
|
||||
},
|
||||
Indices: []*migrator.Index{
|
||||
{Cols: []string{"group", "resource"}, Type: migrator.UniqueIndex},
|
||||
},
|
||||
}
|
||||
mg.AddMigration("create resource_storage_status table", migrator.NewAddTableMigration(resourceStorageStatus))
|
||||
}
|
||||
@@ -10,26 +10,26 @@ import (
|
||||
|
||||
// For *legacy* services, this will indicate if we have transitioned to Unified storage yet
|
||||
type StorageStatus struct {
|
||||
Group string `json:"group" xorm:"group"`
|
||||
Resource string `json:"resource" xorm:"resource"`
|
||||
WriteLegacy bool `json:"write_legacy" xorm:"write_legacy"`
|
||||
WriteUnified bool `json:"write_unified" xorm:"write_unified"`
|
||||
Group string `json:"group"`
|
||||
Resource string `json:"resource"`
|
||||
WriteLegacy bool `json:"write_legacy"`
|
||||
WriteUnified bool `json:"write_unified"`
|
||||
|
||||
// Unified is the primary source (legacy may be secondary)
|
||||
ReadUnified bool `json:"read_unified" xorm:"read_unified"`
|
||||
ReadUnified bool `json:"read_unified"`
|
||||
|
||||
// Timestamp when a migration finished
|
||||
Migrated int64 `json:"migrated" xorm:"migrated"`
|
||||
Migrated int64 `json:"migrated" `
|
||||
|
||||
// Timestamp when a migration *started* this should be cleared when finished
|
||||
// While migrating all write commands will be unavailable
|
||||
Migrating int64 `json:"migrating" xorm:"migrating"`
|
||||
Migrating int64 `json:"migrating"`
|
||||
|
||||
// When false, the behavior will not change at runtime
|
||||
Runtime bool `json:"runtime" xorm:"runtime"`
|
||||
Runtime bool `json:"runtime"`
|
||||
|
||||
// UpdateKey used for optimistic locking -- requests to change the status must match previous value
|
||||
UpdateKey int64 `json:"update_key" xorm:"update_key"`
|
||||
UpdateKey int64 `json:"update_key"`
|
||||
}
|
||||
|
||||
func (status *StorageStatus) validate() bool {
|
||||
|
||||
Reference in New Issue
Block a user