Documentation
¶
Overview ¶
Package shape provides building blocks for dynamic repository loading from struct and DQL sources without requiring persisted YAML artifacts.
Index ¶
- Constants
- Variables
- type CompileColumnDiscoveryMode
- type CompileMixedMode
- type CompileOption
- func WithColumnDiscoveryMode(mode CompileColumnDiscoveryMode) CompileOption
- func WithCompileProfile(profile CompileProfile) CompileOption
- func WithCompileStrict(strict bool) CompileOption
- func WithDQLPathMarker(marker string) CompileOption
- func WithInferTypeContextDefaults(enabled bool) CompileOption
- func WithMixedMode(mode CompileMixedMode) CompileOption
- func WithRoutesRelativePath(path string) CompileOption
- func WithTypeContextPackageDefaults(dir, name, path string) CompileOption
- func WithTypeContextPackageDir(dir string) CompileOption
- func WithTypeContextPackageName(name string) CompileOption
- func WithTypeContextPackagePath(path string) CompileOption
- func WithUnknownNonReadMode(mode CompileUnknownNonReadMode) CompileOption
- type CompileOptions
- type CompileProfile
- type CompileUnknownNonReadMode
- type ComponentArtifact
- type DQLCompiler
- type Engine
- func (e *Engine) LoadComponent(ctx context.Context, src any) (*ComponentArtifact, error)
- func (e *Engine) LoadDQLComponent(ctx context.Context, dql string) (*ComponentArtifact, error)
- func (e *Engine) LoadDQLViews(ctx context.Context, dql string) (*ViewArtifacts, error)
- func (e *Engine) LoadViews(ctx context.Context, src any) (*ViewArtifacts, error)
- type LoadOption
- type LoadOptions
- type Loader
- type Mode
- type Option
- func WithColumnDiscoveryModeDefault(mode CompileColumnDiscoveryMode) Option
- func WithCompileProfileDefault(profile CompileProfile) Option
- func WithCompiler(compiler DQLCompiler) Option
- func WithLegacyTranslatorDefaults() Option
- func WithLoader(loader Loader) Option
- func WithMixedModeDefault(mode CompileMixedMode) Option
- func WithMode(mode Mode) Option
- func WithName(name string) Option
- func WithPlanner(planner Planner) Option
- func WithRuntime(runtime RuntimeRegistrar) Option
- func WithScanner(scanner Scanner) Option
- func WithStrict(strict bool) Option
- func WithUnknownNonReadModeDefault(mode CompileUnknownNonReadMode) Option
- type Options
- type PlanOption
- type PlanOptions
- type PlanResult
- type Planner
- type RuntimeRegistrar
- type ScanOption
- type ScanOptions
- type ScanResult
- type Scanner
- type Source
- type ViewArtifacts
Constants ¶
const ( CompileMixedModeExecWins CompileMixedMode = "exec_wins" CompileMixedModeReadWins CompileMixedMode = "read_wins" CompileMixedModeErrorOnMixed CompileMixedMode = "error_on_mixed" CompileUnknownNonReadWarn CompileUnknownNonReadMode = "warn" CompileUnknownNonReadError CompileUnknownNonReadMode = "error" CompileProfileCompat CompileProfile = "compat" CompileProfileStrict CompileProfile = "strict" CompileColumnDiscoveryAuto CompileColumnDiscoveryMode = "auto" CompileColumnDiscoveryOn CompileColumnDiscoveryMode = "on" CompileColumnDiscoveryOff CompileColumnDiscoveryMode = "off" )
Variables ¶
var ( ErrNilSource = errors.New("shape: source was nil") ErrNilDQL = errors.New("shape: dql was empty") ErrScannerNotConfigured = errors.New("shape: scanner was not configured") ErrPlannerNotConfigured = errors.New("shape: planner was not configured") ErrLoaderNotConfigured = errors.New("shape: loader was not configured") ErrCompilerNotConfigured = errors.New("shape: compiler was not configured") )
Functions ¶
This section is empty.
Types ¶
type CompileColumnDiscoveryMode ¶
type CompileColumnDiscoveryMode string
type CompileMixedMode ¶
type CompileMixedMode string
type CompileOption ¶
type CompileOption func(*CompileOptions)
func WithColumnDiscoveryMode ¶
func WithColumnDiscoveryMode(mode CompileColumnDiscoveryMode) CompileOption
func WithCompileProfile ¶
func WithCompileProfile(profile CompileProfile) CompileOption
func WithCompileStrict ¶
func WithCompileStrict(strict bool) CompileOption
func WithDQLPathMarker ¶
func WithDQLPathMarker(marker string) CompileOption
WithDQLPathMarker overrides the path marker used to locate platform root from source path. Default is "/dql/".
func WithInferTypeContextDefaults ¶
func WithInferTypeContextDefaults(enabled bool) CompileOption
WithInferTypeContextDefaults enables/disables source-path based type context defaults.
func WithMixedMode ¶
func WithMixedMode(mode CompileMixedMode) CompileOption
func WithRoutesRelativePath ¶
func WithRoutesRelativePath(path string) CompileOption
WithRoutesRelativePath overrides routes path relative to detected platform root. Default is "repo/dev/Datly/routes".
func WithTypeContextPackageDefaults ¶
func WithTypeContextPackageDefaults(dir, name, path string) CompileOption
WithTypeContextPackageDefaults sets package dir/name/path in one call.
func WithTypeContextPackageDir ¶
func WithTypeContextPackageDir(dir string) CompileOption
WithTypeContextPackageDir sets default type-context package directory (for xgen parity).
func WithTypeContextPackageName ¶
func WithTypeContextPackageName(name string) CompileOption
WithTypeContextPackageName sets default type-context package name (for xgen parity).
func WithTypeContextPackagePath ¶
func WithTypeContextPackagePath(path string) CompileOption
WithTypeContextPackagePath sets default type-context package import path (for xgen parity).
func WithUnknownNonReadMode ¶
func WithUnknownNonReadMode(mode CompileUnknownNonReadMode) CompileOption
type CompileOptions ¶
type CompileOptions struct {
Strict bool
Profile CompileProfile
MixedMode CompileMixedMode
UnknownNonReadMode CompileUnknownNonReadMode
ColumnDiscoveryMode CompileColumnDiscoveryMode
DQLPathMarker string
RoutesRelativePath string
TypePackageDir string
TypePackageName string
TypePackagePath string
InferTypeContext *bool
}
type CompileProfile ¶
type CompileProfile string
type CompileUnknownNonReadMode ¶
type CompileUnknownNonReadMode string
type ComponentArtifact ¶
ComponentArtifact is the runtime component payload produced by Loader. Component stays untyped in the skeleton to avoid coupling shape package to repository internals before the implementation phase.
func LoadComponent ¶
LoadComponent is a package-level helper for struct source component loading.
func LoadDQLComponent ¶
LoadDQLComponent is a package-level helper for DQL source component loading.
type DQLCompiler ¶
type DQLCompiler interface {
Compile(ctx context.Context, source *Source, opts ...CompileOption) (*PlanResult, error)
}
DQLCompiler compiles DQL source directly into a shape plan.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a thin facade over scan -> plan -> load pipeline.
func (*Engine) LoadComponent ¶
LoadComponent executes scan -> plan -> load for struct source.
func (*Engine) LoadDQLComponent ¶
LoadDQLComponent executes compile -> load for DQL source.
func (*Engine) LoadDQLViews ¶
LoadDQLViews executes compile -> load for DQL source.
type LoadOption ¶
type LoadOption func(*LoadOptions)
type LoadOptions ¶
type LoadOptions struct{}
type Loader ¶
type Loader interface {
LoadViews(ctx context.Context, plan *PlanResult, opts ...LoadOption) (*ViewArtifacts, error)
LoadComponent(ctx context.Context, plan *PlanResult, opts ...LoadOption) (*ComponentArtifact, error)
}
Loader materializes runtime artifacts from normalized plan.
type Mode ¶
type Mode string
Mode controls which execution flow is expected from the shape pipeline.
type Option ¶
type Option func(*Options)
Option mutates Options.
func WithColumnDiscoveryModeDefault ¶
func WithColumnDiscoveryModeDefault(mode CompileColumnDiscoveryMode) Option
WithColumnDiscoveryModeDefault sets default column discovery policy used by Engine DQL compile path.
func WithCompileProfileDefault ¶
func WithCompileProfileDefault(profile CompileProfile) Option
WithCompileProfileDefault sets default compiler profile used by Engine DQL compile path.
func WithCompiler ¶
func WithCompiler(compiler DQLCompiler) Option
func WithLegacyTranslatorDefaults ¶
func WithLegacyTranslatorDefaults() Option
WithLegacyTranslatorDefaults configures Engine compile defaults to legacy-compatible behavior.
func WithLoader ¶
func WithMixedModeDefault ¶
func WithMixedModeDefault(mode CompileMixedMode) Option
WithMixedModeDefault sets default compiler mixed read/exec mode used by Engine DQL compile path.
func WithPlanner ¶
func WithRuntime ¶
func WithRuntime(runtime RuntimeRegistrar) Option
func WithScanner ¶
func WithStrict ¶
func WithUnknownNonReadModeDefault ¶
func WithUnknownNonReadModeDefault(mode CompileUnknownNonReadMode) Option
WithUnknownNonReadModeDefault sets default unknown non-read mode used by Engine DQL compile path.
type Options ¶
type Options struct {
Mode Mode
Strict bool
Name string
Scanner Scanner
Planner Planner
Loader Loader
Compiler DQLCompiler
Runtime RuntimeRegistrar
CompileProfile CompileProfile
CompileMixedMode CompileMixedMode
UnknownNonReadMode CompileUnknownNonReadMode
ColumnDiscoveryMode CompileColumnDiscoveryMode
}
Options stores shape facade dependencies and behavior flags.
type PlanOption ¶
type PlanOption func(*PlanOptions)
type PlanOptions ¶
type PlanOptions struct{}
type PlanResult ¶
PlanResult is the output produced by Planner.
type Planner ¶
type Planner interface {
Plan(ctx context.Context, scan *ScanResult, opts ...PlanOption) (*PlanResult, error)
}
Planner normalizes discovered descriptors into execution plan.
type RuntimeRegistrar ¶
type RuntimeRegistrar interface {
RegisterViews(ctx context.Context, artifacts *ViewArtifacts) error
RegisterComponent(ctx context.Context, artifacts *ComponentArtifact) error
}
RuntimeRegistrar optionally registers loaded artifacts in runtime services.
type ScanOption ¶
type ScanOption func(*ScanOptions)
type ScanOptions ¶
type ScanOptions struct{}
type ScanResult ¶
ScanResult is the output produced by Scanner.
type Scanner ¶
type Scanner interface {
Scan(ctx context.Context, source *Source, opts ...ScanOption) (*ScanResult, error)
}
Scanner discovers shape descriptors from Source.
type Source ¶
type Source struct {
Name string
Path string
Connector string
Struct any
Type reflect.Type
TypeName string
TypeRegistry *x.Registry
DQL string
}
Source represents the caller-provided shape source.
func (*Source) EnsureTypeRegistry ¶
EnsureTypeRegistry returns source registry ensuring root type is registered when available.
type ViewArtifacts ¶
ViewArtifacts is the runtime view payload produced by Loader.
func LoadDQLViews ¶
LoadDQLViews is a package-level helper for DQL source view loading.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compile provides DQL-to-shape compilation.
|
Package compile provides DQL-to-shape compilation. |
|
dql
|
|
|
Package load defines materialization responsibilities for runtime artifacts.
|
Package load defines materialization responsibilities for runtime artifacts. |
|
Package plan defines normalization and shape-planning responsibilities.
|
Package plan defines normalization and shape-planning responsibilities. |
|
Package scan defines scanning responsibilities for struct/DQL inputs.
|
Package scan defines scanning responsibilities for struct/DQL inputs. |