{"modulePath":"github.com/viant/datly","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package reader\n\nPackage 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.\n\n## Constants\n\n```go\nconst ViewDependencyKind = \"view\"\n```\n\n## Types\n\n```go\ntype Config struct {\n\tComponent  *spec.Component\n\tInputType  reflect.Type\n\tOutputType reflect.Type\n\tPlan       *Plan\n\tSQL        *dsql.SQLComponent\n\tReadCaches map[*data.View]cache.Cache\n\t// contains filtered or unexported fields\n}\n```\nConfig contains immutable dependencies for a registered reader execution.\n\n```go\ntype Execution struct {\n\t// contains filtered or unexported fields\n}\n```\nExecution is a concurrency-safe registered reader. Mutable output and relation state are allocated in a fresh Session for every invocation.\n\n```go\nfunc NewExecution(config Config, options ...Option) (*Execution, error)\n```\n\n```go\nfunc (e *Execution) CacheViews() []string\n```\n\n```go\nfunc (e *Execution) InvalidateCache(ctx context.Context, view, scope string) ([]dexec.CacheInvalidation, error)\n```\n\n```go\nfunc (e *Execution) PlanRead(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*dexec.ReadPlan, error)\n```\n\n```go\nfunc (e *Execution) PrepareQuery(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*dexec.PreparedQuery, error)\n```\n\n```go\nfunc (e *Execution) Read(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (any, error)\n```\n\n```go\nfunc (e *Execution) ReadResult(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (*ReadResult, error)\n```\nReadResult opts one invocation into column provenance. Ordinary Read remains allocation-free with respect to this optional evidence graph.\n\n```go\nfunc (e *Execution) Warmup(ctx context.Context, invocation dexec.ReaderWarmupInvocation) (int, error)\n```\nWarmup prepares queries through the same reader owners as normal reads and populates the exact native SQLX cache assigned to each prepared view.\n\n```go\nfunc (e *Execution) WarmupTargets() []dexec.ReaderWarmupTarget\n```\n\n```go\nfunc (e *Execution) WithRecorder(recorder *observability.Recorder) dexec.Reader\n```\nWithRecorder returns a detached execution using an application-owned native metric service. Metadata and typed read plans remain immutable and shared.\n\n```go\ntype Option func(*Service)\n```\n\n```go\nfunc WithRelationFetchConcurrency(concurrency int) Option\n```\n\n```go\ntype Output struct {\n\tMetrics    response.Metrics\n\tData       any\n\tDataType   reflect.Type\n\tDataPtr    any\n\tProjection *readmeta.Result\n}\n```\nOutput carries typed reader output storage for one execution.\n\n```go\ntype Plan struct {\n\tSelectorBindings   []SelectorBindingPlan\n\tViewIndex          *ViewIndex\n\tOutputViewField    string\n\tOutputMetricsField string\n\tOutputStatusField  string\n\tDirectOutput       bool\n\tRoot               *ViewPlan\n\t// contains filtered or unexported fields\n}\n```\nPlan is immutable reader execution metadata compiled during bootstrap.\n\n```go\nfunc NewPlan(config PlanConfig) (*Plan, error)\n```\n\n```go\nfunc (p *Plan) Validate(outputType reflect.Type) error\n```\n\n```go\nfunc (p *Plan) ViewPlanFor(view *data.View) *ViewPlan\n```\n\n```go\ntype PlanConfig struct {\n\tSelectorBindings   []SelectorBindingPlan\n\tViewIndex          *ViewIndex\n\tOutputViewField    string\n\tOutputMetricsField string\n\tOutputStatusField  string\n\tDirectOutput       bool\n\tRootView           *data.View\n\tTemplates          map[*data.View]sqltemplate.Evaluator\n\tCriteria           map[*data.View]*criteria.Compiler\n\tPartitioners       map[*data.View]xreader.Partitioner\n\tCollection         *collector.Graph\n\tCodecs             map[*data.View]*rowcodec.Plan\n}\n```\nPlanConfig contains compiler-owned inputs used to assemble one final reader plan. The temporary maps do not escape into runtime plan state.\n\n```go\ntype ReadResult struct {\n\tData       any\n\tProjection *readmeta.Result\n}\n```\nReadResult carries ordinary typed data plus optional evidence about actual mapped columns at final result ordinals. It does not change row shape.\n\n```go\ntype RelationPlan struct {\n\tRelation *data.Relation\n\tTarget   *ViewPlan\n}\n```\nRelationPlan 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.\n\n```go\ntype SelectorBindingPlan struct {\n\tView       *data.View\n\tProperty   spec.SelectorProperty\n\tFieldIndex []int\n}\n```\nSelectorBindingPlan maps an already-bound input field to a view selector property. Bindly owns value resolution; this plan only describes reader interpretation.\n\n```go\ntype Service struct {\n\t// contains filtered or unexported fields\n}\n```\nService is the rebuilt reader capability. It restores a reader-owned execution center rather than pushing read behavior back into the root runtime facade.\n\n```go\nfunc NewService(options ...Option) *Service\n```\n\n```go\nfunc (s *Service) Read(ctx context.Context, session *Session, input any, binder xhandler.Binder) (_ any, err error)\n```\nRead executes a compiled reader request with input already prepared by the unified handler engine. Binding and transport concerns stay outside SQL.\n\n```go\ntype Session struct {\n\tComponent         *spec.Component\n\tInputType         reflect.Type\n\tOutputType        reflect.Type\n\tArtifact          *Plan\n\tSQL               *dsql.SQLComponent\n\tReadCaches        map[*data.View]cache.Cache\n\tParameters        sqlx.ParameterResolver\n\tCollectProjection bool\n\tDryRun            bool\n\tRefreshCache      bool\n\tCacheOnly         bool\n\tQueryScope        *sqlxread.QueryScope\n\n\tOutput\n\t// contains filtered or unexported fields\n}\n```\nSession contains only SQL reader execution state. Input binding, transport, handler capabilities, and registration remain runtime concerns.\n\n```go\nfunc (s *Session) Init() error\n```\n\n```go\ntype ViewDependency struct {\n\tName       string\n\tTargetType reflect.Type\n\tComponent  *spec.Component\n\tInputType  reflect.Type\n\tPlan       *Plan\n}\n```\nViewDependency is one immutable, typed independent-view read compiled from a component input binding.\n\n```go\ntype ViewIndex struct {\n\t// contains filtered or unexported fields\n}\n```\nViewIndex 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.\n\n```go\nfunc NewViewIndex(component *spec.Component, root *data.View) *ViewIndex\n```\n\n```go\nfunc (i *ViewIndex) Resolve(alias string) (*data.View, error)\n```\n\n```go\ntype ViewPlan struct {\n\tView        *data.View\n\tTemplate    sqltemplate.Evaluator\n\tCriteria    *criteria.Compiler\n\tConnector   string\n\tPartitioner xreader.Partitioner\n\tCollector   *collector.View\n\tCodec       *rowcodec.Plan\n\tRelations   []*RelationPlan\n}\n```\nViewPlan 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.\n\n","path":"github.com/viant/datly/sql/reader","name":"reader","synopsis":"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.","isRedistributable":true}
