schema

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StepBaseProjectDDL = "base_project_ddl"
	StepTenantDDL      = "tenant_ddl"
	StepSystemSchema   = "system_schema"
	StepCache          = "cache"
)

Variables

This section is empty.

Functions

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 PhysicalDDLRequired

func PhysicalDDLRequired(ctx context.Context) bool

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

func Run(h Hooks, in RunInput) error

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.

func WithPhysicalDDLRequired

func WithPhysicalDDLRequired(ctx context.Context, required bool) context.Context

WithPhysicalDDLRequired annotates ctx when publish should flush project/tenant replicas.

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 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.

Jump to

Keyboard shortcuts

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