reader

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package reader owns immutable SQL read plans and SQLX-backed execution with fresh invocation sessions, typed rows, relations, partitions, hooks, and the native SQLX cache path.

Index

Constants

View Source
const ViewDependencyKind = "view"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Component  *spec.Component
	InputType  reflect.Type
	OutputType reflect.Type
	Plan       *Plan
	SQL        *dsql.SQLComponent
	ReadCaches map[*data.View]cache.Cache
	// contains filtered or unexported fields
}

Config contains immutable dependencies for a registered reader execution.

type Execution

type Execution struct {
	// contains filtered or unexported fields
}

Execution is a concurrency-safe registered reader. Mutable output and relation state are allocated in a fresh Session for every invocation.

func NewExecution

func NewExecution(config Config, options ...Option) (*Execution, error)

func (*Execution) CacheViews added in v1.1.0

func (e *Execution) CacheViews() []string

func (*Execution) InvalidateCache added in v1.1.0

func (e *Execution) InvalidateCache(ctx context.Context, view, scope string) ([]dexec.CacheInvalidation, error)

func (*Execution) PlanRead

func (e *Execution) PlanRead(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*dexec.ReadPlan, error)

func (*Execution) PrepareQuery

func (e *Execution) PrepareQuery(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*dexec.PreparedQuery, error)

func (*Execution) Read

func (e *Execution) Read(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (any, error)

func (*Execution) ReadResult

func (e *Execution) ReadResult(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*ReadResult, error)

ReadResult opts one invocation into column provenance. Ordinary Read remains allocation-free with respect to this optional evidence graph.

func (*Execution) Warmup

func (e *Execution) Warmup(ctx context.Context, invocation dexec.ReaderWarmupInvocation) (int, error)

Warmup prepares queries through the same reader owners as normal reads and populates the exact native SQLX cache assigned to each prepared view.

func (*Execution) WarmupTargets

func (e *Execution) WarmupTargets() []dexec.ReaderWarmupTarget

func (*Execution) WithRecorder

func (e *Execution) WithRecorder(recorder *observability.Recorder) dexec.Reader

WithRecorder returns a detached execution using an application-owned native metric service. Metadata and typed read plans remain immutable and shared.

type Option

type Option func(*Service)

func WithRelationFetchConcurrency

func WithRelationFetchConcurrency(concurrency int) Option

type Output

type Output struct {
	Metrics    response.Metrics
	Data       any
	DataType   reflect.Type
	DataPtr    any
	Projection *readmeta.Result
}

Output carries typed reader output storage for one execution.

type Plan

type Plan struct {
	SelectorBindings   []SelectorBindingPlan
	ViewIndex          *ViewIndex
	OutputViewField    string
	OutputMetricsField string
	OutputStatusField  string
	DirectOutput       bool
	Root               *ViewPlan
	// contains filtered or unexported fields
}

Plan is immutable reader execution metadata compiled during bootstrap.

func NewPlan

func NewPlan(config PlanConfig) (*Plan, error)

func (*Plan) Validate

func (p *Plan) Validate(outputType reflect.Type) error

func (*Plan) ViewPlanFor

func (p *Plan) ViewPlanFor(view *data.View) *ViewPlan

type PlanConfig

type PlanConfig struct {
	SelectorBindings   []SelectorBindingPlan
	ViewIndex          *ViewIndex
	OutputViewField    string
	OutputMetricsField string
	OutputStatusField  string
	DirectOutput       bool
	RootView           *data.View
	Templates          map[*data.View]sqltemplate.Evaluator
	Criteria           map[*data.View]*criteria.Compiler
	Partitioners       map[*data.View]xreader.Partitioner
	Collection         *collector.Graph
	Codecs             map[*data.View]*rowcodec.Plan
}

PlanConfig contains compiler-owned inputs used to assemble one final reader plan. The temporary maps do not escape into runtime plan state.

type ReadResult

type ReadResult struct {
	Data       any
	Projection *readmeta.Result
}

ReadResult carries ordinary typed data plus optional evidence about actual mapped columns at final result ordinals. It does not change row shape.

type RelationPlan

type RelationPlan struct {
	Relation *data.Relation
	Target   *ViewPlan
}

RelationPlan is one graph edge from a parent view plan to its target plan. Target may point to an existing shared node. Executable dependency edges remain acyclic; recursive row data uses the view's self-reference metadata.

type SelectorBindingPlan

type SelectorBindingPlan struct {
	View       *data.View
	Property   spec.SelectorProperty
	FieldIndex []int
}

SelectorBindingPlan maps an already-bound input field to a view selector property. Bindly owns value resolution; this plan only describes reader interpretation.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the rebuilt reader capability. It restores a reader-owned execution center rather than pushing read behavior back into the root runtime facade.

func NewService

func NewService(options ...Option) *Service

func (*Service) Read

func (s *Service) Read(ctx context.Context, session *Session, input any, binder xhandler.Binder) (_ any, err error)

Read executes a compiled reader request with input already prepared by the unified handler engine. Binding and transport concerns stay outside SQL.

type Session

type Session struct {
	Component         *spec.Component
	InputType         reflect.Type
	OutputType        reflect.Type
	Artifact          *Plan
	SQL               *dsql.SQLComponent
	ReadCaches        map[*data.View]cache.Cache
	Parameters        sqlx.ParameterResolver
	CollectProjection bool
	DryRun            bool
	RefreshCache      bool
	CacheOnly         bool
	QueryScope        *sqlxread.QueryScope

	Output
	// contains filtered or unexported fields
}

Session contains only SQL reader execution state. Input binding, transport, handler capabilities, and registration remain runtime concerns.

func (*Session) Init

func (s *Session) Init() error

type ViewDependency

type ViewDependency struct {
	Name       string
	TargetType reflect.Type
	Component  *spec.Component
	InputType  reflect.Type
	Plan       *Plan
}

ViewDependency is one immutable, typed independent-view read compiled from a component input binding.

type ViewIndex

type ViewIndex struct {
	// contains filtered or unexported fields
}

ViewIndex is the immutable registration-time index of prepared views. Aliases may be duplicated; ambiguity is reported only when that alias is selected, so unrelated repeated child names remain valid.

func NewViewIndex

func NewViewIndex(component *spec.Component, root *data.View) *ViewIndex

func (*ViewIndex) Resolve

func (i *ViewIndex) Resolve(alias string) (*data.View, error)

type ViewPlan

type ViewPlan struct {
	View        *data.View
	Template    sqltemplate.Evaluator
	Criteria    *criteria.Compiler
	Connector   string
	Partitioner xreader.Partitioner
	Collector   *collector.View
	Codec       *rowcodec.Plan
	Relations   []*RelationPlan
}

ViewPlan is immutable execution metadata for one view in a reader graph. Runtime services consume this node directly instead of joining parallel maps of view-scoped behavior on every read.

Directories

Path Synopsis
Package collector owns reader-compiled relation graphs and typed row assembly.
Package collector owns reader-compiled relation graphs and typed row assembly.
Package compiler converts canonical view metadata and typed contracts into immutable SQL reader plans.
Package compiler converts canonical view metadata and typed contracts into immutable SQL reader plans.
Package provider adapts SQL reader dependencies to Bindly providers.
Package provider adapts SQL reader dependencies to Bindly providers.
Package readmeta carries immutable evidence from actual typed SQL reads.
Package readmeta carries immutable evidence from actual typed SQL reads.
Package rowcodec compiles column codecs into typed SQLX scan wrappers.
Package rowcodec compiles column codecs into typed SQLX scan wrappers.

Jump to

Keyboard shortcuts

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