compiler

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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:

  1. CLASSIFY — definitions → toAdd/toDrop; check for extensions
  2. BUILD SOURCE NAMES (from baseCatalog + changes)
  3. TYPE DROPS — emit @drop DDL for types + derived types + shared fields
  4. PREPARE — prefix rename on definitions AND extensions
  5. COMPILE NEW TYPES — GENERATE→ASSEMBLE→FINALIZE on toAdd definitions
  6. COMPILE FIELD CHANGES — process extensions for field add/drop/replace
  7. RETURN CompiledCatalog

func GlobalRules

func GlobalRules() []base.Rule

GlobalRules returns all registered rules.

func RegisterRules

func RegisterRules(rules ...base.Rule)

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 New

func New(rules ...base.Rule) *Compiler

New creates a Compiler with the given rules sorted by phase.

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.

type Options

type Options = base.Options

Options is an alias for base.Options for backward compatibility.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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