Documentation
¶
Index ¶
- func Compile(ctx context.Context, provider base.Provider, source base.DefinitionsSource, ...) (base.CompiledCatalog, error)
- func CompileChanges(ctx context.Context, provider base.Provider, ...) (base.CompiledCatalog, error)
- func GlobalRules() []base.Rule
- func RegisterRules(rules ...base.Rule)
- type Catalog
- type Compiler
- type EngineCapabilities
- type EngineDeleteCapabilities
- type EngineGeneralCapabilities
- type EngineInsertCapabilities
- type EngineUpdateCapabilities
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(ctx context.Context, provider base.Provider, source base.DefinitionsSource, opts Options) (base.CompiledCatalog, error)
Compile is a convenience function that creates a Compiler from GlobalRules() and compiles the given source against the target schema.
func CompileChanges ¶
func CompileChanges( ctx context.Context, provider base.Provider, baseCatalog base.DefinitionsSource, changes base.DefinitionsSource, opts Options, ) (base.CompiledCatalog, error)
CompileChanges compiles incremental DDL SDL changes against an existing provider schema. It produces a CompiledCatalog compatible with Provider.Update().
Parameters:
- provider: the current compiled schema
- baseCatalog: the full original (uncompiled) source catalog — needed for prefix renaming of type references across the whole catalog namespace
- changes: incremental DDL with @drop directives on types to remove, new definitions for types to add, and extensions for field-level changes
- opts: compile options (same as for full compilation)
The pipeline:
- CLASSIFY — definitions → toAdd/toDrop; check for extensions
- BUILD SOURCE NAMES (from baseCatalog + changes)
- TYPE DROPS — emit @drop DDL for types + derived types + shared fields
- PREPARE — prefix rename on definitions AND extensions
- COMPILE NEW TYPES — GENERATE→ASSEMBLE→FINALIZE on toAdd definitions
- COMPILE FIELD CHANGES — process extensions for field add/drop/replace
- RETURN CompiledCatalog
func RegisterRules ¶
RegisterRules adds rules to the global rule registry. Typically called from init() in rules/ or engine packages.
Types ¶
type Catalog ¶
type Catalog interface {
base.DefinitionsSource
CompileOptions() Options
}
Catalog is a source of definitions with compile options. Used by pkg/schema to pass catalog sources to compilation.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler orchestrates 5-phase rule-based schema compilation.
func (*Compiler) Compile ¶
func (c *Compiler) Compile( ctx context.Context, schema base.Provider, source base.DefinitionsSource, opts base.Options, ) (base.CompiledCatalog, error)
Compile executes 5-phase compilation of source definitions against the target schema. Returns a CompiledCatalog (DDL feed) that can be applied via Provider.Update().
func (*Compiler) CompileChanges ¶
func (c *Compiler) CompileChanges( ctx context.Context, provider base.Provider, baseCatalog base.DefinitionsSource, changes base.DefinitionsSource, opts base.Options, ) (base.CompiledCatalog, error)
CompileChanges compiles incremental DDL changes using the compiler's rules.
type EngineCapabilities ¶
type EngineCapabilities = base.EngineCapabilities
EngineCapabilities is an alias for base.EngineCapabilities.
type EngineDeleteCapabilities ¶
type EngineDeleteCapabilities = base.EngineDeleteCapabilities
EngineDeleteCapabilities is an alias for base.EngineDeleteCapabilities.
type EngineGeneralCapabilities ¶
type EngineGeneralCapabilities = base.EngineGeneralCapabilities
EngineGeneralCapabilities is an alias for base.EngineGeneralCapabilities.
type EngineInsertCapabilities ¶
type EngineInsertCapabilities = base.EngineInsertCapabilities
EngineInsertCapabilities is an alias for base.EngineInsertCapabilities.
type EngineUpdateCapabilities ¶
type EngineUpdateCapabilities = base.EngineUpdateCapabilities
EngineUpdateCapabilities is an alias for base.EngineUpdateCapabilities.