Documentation
¶
Index ¶
- Constants
- func ExpectedPhysicalColumns(model *models.ModelType) []string
- func ListRepairable(ctx context.Context, store interfaces.SchemaOperationsStore, projectID string, ...) ([]*models.SchemaOperation, error)
- func ModelIsCommonFromExt(m *models.ModelType) bool
- func PhysicalDDLRequired(ctx context.Context) bool
- func ReconcileOneOperation(h Hooks, in ReconcileInput) (*models.SchemaOperation, error)
- func Run(h Hooks, in RunInput) error
- func RunBackgroundReconciler(ctx context.Context, h Hooks, projectID string, interval time.Duration)
- func StoreFromSystemDriver(sys interfaces.ApitoSystemDB) interfaces.SchemaOperationsStore
- func WithPhysicalDDLRequired(ctx context.Context, required bool) context.Context
- type Hooks
- type ModelPhysicalHealth
- type ReconcileInput
- type RunInput
Constants ¶
const ( StepBaseProjectDDL = "base_project_ddl" StepTenantDDL = "tenant_ddl" StepSystemSchema = "system_schema" StepCache = "cache" )
Variables ¶
This section is empty.
Functions ¶
func ExpectedPhysicalColumns ¶ added in v1.8.13
ExpectedPhysicalColumns returns top-level SQL columns implied by the model schema (id + field identifiers / locale expansions). Nested object/repeated children are not separate columns (parent is JSON).
func ListRepairable ¶
func ListRepairable(ctx context.Context, store interfaces.SchemaOperationsStore, projectID string, limit int) ([]*models.SchemaOperation, error)
ListRepairable returns operations that need reconciliation for a project.
func ModelIsCommonFromExt ¶ added in v1.8.13
ModelIsCommonFromExt reads SaaS common-model flag from Ext (open-core safe).
func PhysicalDDLRequired ¶
PhysicalDDLRequired reports whether project/tenant sync flush is needed after schema commit.
func ReconcileOneOperation ¶
func ReconcileOneOperation(h Hooks, in ReconcileInput) (*models.SchemaOperation, error)
ReconcileOneOperation retries idempotent steps for failed / needs_repair / applying operations.
func Run ¶
Run executes base DDL → tenant DDL → system persist → cache with optional ledger + compensation.
func RunBackgroundReconciler ¶
func RunBackgroundReconciler(ctx context.Context, h Hooks, projectID string, interval time.Duration)
RunBackgroundReconciler periodically lists repairable operations for observability. Full automatic replay requires operation-specific handlers; mutations remain synchronous.
func StoreFromSystemDriver ¶
func StoreFromSystemDriver(sys interfaces.ApitoSystemDB) interfaces.SchemaOperationsStore
StoreFromSystemDriver returns SchemaOperationsStore when the system driver implements it.
Types ¶
type Hooks ¶
type Hooks struct {
SchemaIterate func(ctx context.Context, project *models.Project, fn func(ctx context.Context, driver interface{}) error) error
Store interfaces.SchemaOperationsStore
// AfterCommit runs after all orchestration steps succeed (base DDL, tenants, system persist, cache).
AfterCommit func(in RunInput)
}
Hooks wires tenant propagation and optional ledger persistence.
type ModelPhysicalHealth ¶ added in v1.8.13
type ModelPhysicalHealth struct {
ModelName string `json:"model_name"`
TableExists bool `json:"table_exists"`
PhysicalColumns []string `json:"physical_columns"`
ExpectedColumns []string `json:"expected_columns"`
MissingColumns []string `json:"missing_columns"`
ExtraColumns []string `json:"extra_columns"`
IsCommonModel bool `json:"is_common_model"`
Warnings []string `json:"warnings"`
}
ModelPhysicalHealth is the read-only comparison of logical schema fields against physical table columns (no DDL).
func BuildModelPhysicalHealth ¶ added in v1.8.13
func BuildModelPhysicalHealth( model *models.ModelType, tableExists bool, physicalColumns []string, ) ModelPhysicalHealth
BuildModelPhysicalHealth diffs expected vs physical columns and adds warnings.
type ReconcileInput ¶
type ReconcileInput struct {
Ctx context.Context
Op *models.SchemaOperation
BaseDriver interfaces.ProjectDBInterface
ApplyDDL func(driver interfaces.ProjectDBInterface) error
PersistSystem func() error
RefreshCache func() error
Compensate func(driver interfaces.ProjectDBInterface) error
}
ReconcileInput retries or reports repair for one ledger operation.
type RunInput ¶
type RunInput struct {
Ctx context.Context
Project *models.Project
OperationType string
Request interface{}
BaseDriver interfaces.ProjectDBInterface
SkipBaseDDL bool
ApplyDDL func(driver interfaces.ProjectDBInterface) error
PersistSystem func() error
RefreshCache func() error
// Compensate runs on base project driver after partial success (best-effort).
Compensate func(driver interfaces.ProjectDBInterface) error
// PhysicalDDLRequired when true tells PostSchemaChangeHook to flush project/tenant replicas.
PhysicalDDLRequired bool
}
RunInput is one synchronous schema mutation coordinated by the orchestrator.