pipeline

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package pipeline orchestrates the entire code generation process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiagnosticsError

type DiagnosticsError struct {
	Diagnostic queryanalyzer.Diagnostic
	Cause      error
}

DiagnosticsError indicates that errors were reported via diagnostics.

func (*DiagnosticsError) Error

func (e *DiagnosticsError) Error() string

func (*DiagnosticsError) Unwrap

func (e *DiagnosticsError) Unwrap() error

type Environment

type Environment struct {
	FSResolver    func(string) (fileset.Resolver, error)
	Logger        logging.Logger
	Writer        Writer
	SchemaParser  schemaparser.SchemaParser // injectable schema parser (deprecated: use Engine)
	Generator     codegen.Generator         // injectable generator
	Cache         cache.Cache               // injectable cache
	Engine        engine.Engine             // injectable database engine
	Verifier      verify.Verifier           // optional; nil => pure static analysis
	VerifiedCache *verify.Cache             // committed verified types loaded by the CLI; nil = none
}

Environment captures external dependencies used by the pipeline.

type Hooks

type Hooks struct {
	// BeforeParse is called before parsing schema files.
	// Return an error to abort the pipeline.
	BeforeParse func(ctx context.Context, schemaPaths []string) error

	// AfterParse is called after all schemas are parsed.
	// Return an error to abort the pipeline.
	AfterParse func(ctx context.Context, catalog *model.Catalog) error

	// BeforeAnalyze is called before analyzing queries.
	// Return an error to abort the pipeline.
	BeforeAnalyze func(ctx context.Context, queryPaths []string) error

	// AfterAnalyze is called after all queries are analyzed.
	// Return an error to abort the pipeline.
	AfterAnalyze func(ctx context.Context, analyses []analyzer.Result) error

	// BeforeGenerate is called before generating code.
	// Return an error to abort the pipeline.
	BeforeGenerate func(ctx context.Context, analyses []analyzer.Result) error

	// AfterGenerate is called after code is generated.
	// Return an error to abort the pipeline.
	AfterGenerate func(ctx context.Context, files []codegen.File) error

	// BeforeWrite is called before writing files.
	// Return an error to abort the pipeline.
	BeforeWrite func(ctx context.Context, files []codegen.File) error

	// AfterWrite is called after all files are written.
	// This is the final hook, called even if earlier stages failed.
	AfterWrite func(ctx context.Context, summary Summary) error
}

Hooks provides extension points in the pipeline execution. Each hook is called at a specific stage and can modify behavior or perform side effects.

func NoHooks

func NoHooks() Hooks

NoHooks returns a Hooks with all nil functions (no-op).

func (Hooks) Chain

func (h Hooks) Chain(other Hooks) Hooks

Chain combines two Hooks, calling h's hooks first, then other's hooks. If a hook in h returns an error, other's hook is not called.

type MemoryWriter

type MemoryWriter struct {
	Files map[string][]byte
	// contains filtered or unexported fields
}

MemoryWriter implements Writer for testing without filesystem I/O.

func (*MemoryWriter) Clear

func (m *MemoryWriter) Clear()

Clear removes all files.

func (*MemoryWriter) FileCount

func (m *MemoryWriter) FileCount() int

FileCount returns the number of files.

func (*MemoryWriter) GetFile

func (m *MemoryWriter) GetFile(path string) ([]byte, bool)

GetFile retrieves a file's content.

func (*MemoryWriter) HasFile

func (m *MemoryWriter) HasFile(path string) bool

HasFile checks if a file exists.

func (*MemoryWriter) WriteFile

func (m *MemoryWriter) WriteFile(path string, data []byte) error

WriteFile stores data in memory.

type Pipeline

type Pipeline struct {
	Env   Environment
	Hooks Hooks // extension hooks
}

Pipeline orchestrates configuration loading, analysis, and code generation.

func (*Pipeline) Run

func (p *Pipeline) Run(ctx context.Context, opts RunOptions) (summary Summary, err error)

Run executes the pipeline according to the provided options.

type RunOptions

type RunOptions struct {
	ConfigPath          string
	OutOverride         string
	DryRun              bool
	ListQueries         bool
	StrictConfig        bool
	NoJSONTags          bool
	EmitPointersForNull bool
	SQLDialect          string
	EmitIFNotExists     bool
	// SkipVerifiedCache suppresses the applyVerifiedCache branch even when
	// [verify] is enabled. Used by the 'verify' subcommand's internal dry-run
	// so it does not emit a spurious "no verified cache" warning/error.
	SkipVerifiedCache bool
}

RunOptions configures a pipeline execution.

type Summary

type Summary struct {
	Files       []codegen.File
	Diagnostics []queryanalyzer.Diagnostic
	Analyses    []queryanalyzer.Result
	Catalog     *model.Catalog
}

Summary captures generated files and diagnostics collected during a run.

type WriteError

type WriteError struct {
	Path string
	Err  error
}

WriteError wraps failures encountered while writing generated files.

func (*WriteError) Error

func (e *WriteError) Error() string

func (*WriteError) Unwrap

func (e *WriteError) Unwrap() error

type Writer

type Writer interface {
	WriteFile(path string, data []byte) error
}

Writer writes generated files to persistent storage.

func NewOSWriter

func NewOSWriter() Writer

NewOSWriter returns a Writer that performs atomic writes on the local filesystem.

Jump to

Keyboard shortcuts

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