Documentation
¶
Overview ¶
Package exec defines narrow execution ports consumed across Datly runtime and SQL ownership boundaries.
Index ¶
- Constants
- Variables
- func AllowsReportOrdering(ctx context.Context, component spec.Key, view string) bool
- func BeginOutputSelection(ctx context.Context)
- func CaptureChildOutputSelection(ctx context.Context) context.Context
- func CaptureOutputSelection(ctx context.Context) context.Context
- func EnterReportOrdering(ctx context.Context, target ComponentTarget, permission *ReportOrdering) (context.Context, error)
- func ErrorMessage(err error, status int) string
- func InvocationTransaction(ctx context.Context, db *sql.DB) (*sql.Tx, error)
- func PublishOutputSelection(ctx context.Context, result any, filter OutputFieldFilter)
- func ReportOrderingFields(ctx context.Context, component spec.Key, view string) []string
- func ScopeOutputSelection(ctx context.Context) (context.Context, func(any, error))
- func ValidateCacheScope(scope string) error
- func WantsOutputSelection(ctx context.Context) bool
- func WithInvocationTransactionLookup(ctx context.Context, lookup func(context.Context, *sql.DB) (*sql.Tx, error)) context.Context
- type CacheInvalidation
- type CacheServiceInvalidator
- type ComponentInvoker
- type ComponentRequest
- type ComponentTarget
- type ConnectorDataSourceProvider
- type DataSource
- type OutputFieldFilter
- type PanicError
- type PredicateEvaluator
- type PreparedQuery
- type ProjectionReader
- type ProjectionRequest
- type ProviderScope
- type QueryPreparer
- type ReadPlan
- type ReadPlanner
- type Reader
- type ReaderCacheManager
- type ReaderInput
- type ReaderInputPreparer
- type ReaderOptions
- type ReaderWarmer
- type ReaderWarmupInvocation
- type ReaderWarmupRequest
- type ReaderWarmupTarget
- type ReaderWarmupTargeter
- type ReportOrdering
Constants ¶
const ComponentInvokerKey xhandler.ValueKey = "component_invoker"
const PredicateVariable = "predicate"
const ReaderInputPreparerKey xhandler.ValueKey = "reader_input_preparer"
Variables ¶
var ErrCacheViewNotFound = errors.New("cached view not found")
Functions ¶
func AllowsReportOrdering ¶ added in v1.1.0
AllowsReportOrdering checks the exact component and canonical view. Runtime has already checked the route when entering this invocation.
func BeginOutputSelection ¶
BeginOutputSelection excludes input preparation reads from output selection.
func CaptureChildOutputSelection ¶
CaptureChildOutputSelection isolates one explicitly delegated output read. The caller must publish SelectedOutputFields(childContext, childResult) for its own result, and is responsible for preserving the filter's field paths. Ordinary child/input/sibling reads never inherit this publication authority.
func CaptureOutputSelection ¶
CaptureOutputSelection installs a transport-owned result slot. Typed handler results remain unchanged; explicit response and custom marshal owners can ignore it.
func EnterReportOrdering ¶ added in v1.1.0
func EnterReportOrdering(ctx context.Context, target ComponentTarget, permission *ReportOrdering) (context.Context, error)
EnterReportOrdering replaces, rather than inherits, the parent's permission. Runtime calls it at every component boundary, including input dependencies.
func ErrorMessage ¶
ErrorMessage projects errors without an explicit response.BodyError payload. Authored binding messages remain intentional policy, including ${error}; unclassified server failures never acquire a public diagnostic message.
func InvocationTransaction ¶ added in v1.1.0
InvocationTransaction returns the active transaction for one exact database handle. It does not transfer commit or rollback ownership to the caller.
func PublishOutputSelection ¶
func PublishOutputSelection(ctx context.Context, result any, filter OutputFieldFilter)
PublishOutputSelection records a completed typed reader result in this frame. A sealed frame ignores reads initiated by output finalizers.
func ReportOrderingFields ¶ added in v1.1.0
ReportOrderingFields returns a detached set of selected scalar identities. Hidden relation keys do not become sortable merely by entering SQL projection.
func ScopeOutputSelection ¶
ScopeOutputSelection shadows parent state at every canonical component entry. Only the outer frame can publish to the transport, after its handler returns.
func ValidateCacheScope ¶ added in v1.1.0
func WantsOutputSelection ¶
WantsOutputSelection lets ordinary typed reader calls avoid wire compilation.
func WithInvocationTransactionLookup ¶ added in v1.1.0
func WithInvocationTransactionLookup(ctx context.Context, lookup func(context.Context, *sql.DB) (*sql.Tx, error)) context.Context
WithInvocationTransactionLookup lets SQL readers find the transaction owned by the first endpoint invocation. The lookup runs when a connector resolves, after an imperative child writer may have started that transaction.
Types ¶
type CacheInvalidation ¶ added in v1.1.0
type CacheServiceInvalidator ¶ added in v1.1.0
CacheServiceInvalidator lets supplied cache services support administration without importing Datly's internal generation implementation.
type ComponentInvoker ¶
type ComponentInvoker interface {
InvokeComponent(context.Context, ComponentRequest) (any, error)
}
type ComponentRequest ¶
type ComponentRequest struct {
Target ComponentTarget
Input any
// Replay is a native binding seed, never pre-bound component input.
Replay *bindly.ReplayBinding
// BindingOutput supplies the calling output to explicitly declared output bindings.
BindingOutput any
Providers []locator.Provider
// Completion observes canonical managed-transaction evidence for this root.
// It is trusted service metadata and never client-bindable.
Completion func(xhandler.Outcome)
// PrepareQuery requests a bound root query through the same input lifecycle.
// It is a trusted component capability, never a transport request option.
PrepareQuery bool
// DryRun plans an ordinary reader root without opening a row reader.
// Input initialization, providers and SQL templates still run.
DryRun bool
// ReaderOptions apply after canonical input binding, to the target reader's
// result graph. Dependency binding retains its own invocation context policy.
ReaderOptions *ReaderOptions
// ReportOrdering is explicit report-only ordering permission. It is never
// inherited by child calls and does not enable pagination or other selectors.
ReportOrdering *ReportOrdering
// WarmupOmitInput names trusted warmup-owned inputs that are intentionally
// absent from canonical transport binding, such as an indexed warmup key.
WarmupOmitInput []string
Warmup *ReaderWarmupRequest
}
ComponentRequest invokes an exact target. Input is reserved for a trusted caller that already owns the canonical typed component input.
type ComponentTarget ¶
ComponentTarget identifies one exact component route.
func (ComponentTarget) String ¶
func (t ComponentTarget) String() string
type ConnectorDataSourceProvider ¶ added in v1.1.0
type ConnectorDataSourceProvider interface {
ConnectorDataSource(ctx context.Context, name string) (DataSource, error)
}
ConnectorDataSourceProvider supplies a lazy source for an explicitly named connector. The SQL layer owns source construction; the invocation engine owns its transaction lifecycle. Unknown names must not select a default.
type DataSource ¶
DataSource opens one lazy handler data capability for an invocation.
type OutputFieldFilter ¶
OutputFieldFilter is an invocation's user projection, independent of loaded columns and per-row read evidence. Paths follow the native JSON encoder.
func SelectedOutputFields ¶
func SelectedOutputFields(ctx context.Context, value any) OutputFieldFilter
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
PanicError retains recovery diagnostics privately. It deliberately does not unwrap the panic value: panic(response.Error) is not an intentional response. Cause and Stack are for operator diagnostics, never protocol serialization.
func NewPanicError ¶
func NewPanicError(operation string, cause any) *PanicError
NewPanicError must be called at the recovering boundary, before its stack unwinds. The standard server log receives diagnostics even without a logger.
func (*PanicError) Cause ¶
func (e *PanicError) Cause() any
func (*PanicError) Error ¶
func (e *PanicError) Error() string
func (*PanicError) Stack ¶
func (e *PanicError) Stack() []byte
type PredicateEvaluator ¶
type PredicateEvaluator interface {
ContextType() reflect.Type
NewContext(context.Context, xhandler.Binder, func(...any)) (any, error)
}
PredicateEvaluator supplies a typed template context without exposing the concrete predicate implementation to SQL template compilation.
type PreparedQuery ¶
type PreparedQuery struct {
SQL string
Args []any
Projection ProjectionReader
}
PreparedQuery contains bound source SQL and a projection executor owned by that source connection. No database or transaction is exposed to handlers.
type ProjectionReader ¶
type ProjectionReader interface {
ReadProjection(context.Context, ProjectionRequest) (any, error)
}
type ProjectionRequest ¶
type ProviderScope ¶
ProviderScope supplies invocation-local providers without coupling protocol adapters to the concrete runtime engine.
type QueryPreparer ¶
type QueryPreparer interface {
PrepareQuery(context.Context, any, xhandler.Binder, sqlx.ParameterResolver) (*PreparedQuery, error)
}
QueryPreparer is an optional capability of a compiled SQL reader.
type ReadPlan ¶
ReadPlan contains the bound root query with its effective pagination. It grants no execution capability and does not promise whole-invocation purity.
type ReadPlanner ¶
type Reader ¶
type Reader interface {
Read(ctx context.Context, input any, binder xhandler.Binder, resolver sqlx.ParameterResolver) (any, error)
}
Reader executes one read using input already prepared by the unified handler engine. SQL plans, connections, caches, and mutable reader state remain private to the implementation.
type ReaderCacheManager ¶ added in v1.1.0
type ReaderCacheManager interface {
CacheViews() []string
InvalidateCache(context.Context, string, string) ([]CacheInvalidation, error)
}
ReaderCacheManager is a server-owned capability. HTTP callers require an independent administrator policy before this operation is invoked.
type ReaderInput ¶
type ReaderInput struct {
Input any
Binder xhandler.Binder
Parameters sqlx.ParameterResolver
}
ReaderInput carries invocation values only. Bindly projections stay owned by the canonical registry contract and its DI adapter.
type ReaderInputPreparer ¶
type ReaderInputPreparer func(context.Context, ...string) (*ReaderInput, error)
type ReaderOptions ¶
type ReaderOptions struct {
RefreshCache bool
CacheOnly bool
QueryScope *sqlxread.QueryScope
}
ReaderOptions are trusted invocation controls, shared by nested reader work. Cache ownership and identity remain with SQLX. Transactional views bypass shared caches, including refresh/writeback, and reject CacheOnly rather than silently falling back to SQL execution.
func ReaderOptionsFromContext ¶
func ReaderOptionsFromContext(ctx context.Context) ReaderOptions
type ReaderWarmer ¶
type ReaderWarmer interface {
Warmup(context.Context, ReaderWarmupInvocation) (int, error)
}
ReaderWarmer is an optional reader operation; native SQLX owns all cache data.
type ReaderWarmupInvocation ¶
type ReaderWarmupInvocation struct {
Request ReaderWarmupRequest
Input any
Binder xhandler.Binder
Parameters sqlx.ParameterResolver
}
ReaderWarmupInvocation carries canonical input already bound by the engine.
type ReaderWarmupRequest ¶
type ReaderWarmupRequest struct {
View string
Settings *spec.CacheWarmupSettings
}
ReaderWarmupRequest selects one prepared view and its authored warmup policy. It is a trusted startup/operational request, not a transport parameter.
type ReaderWarmupTarget ¶
type ReaderWarmupTarget struct {
View string
Settings *spec.CacheWarmupSettings
}
ReaderWarmupTarget is one materialized view warmup policy owned by a reader.
type ReaderWarmupTargeter ¶
type ReaderWarmupTargeter interface {
WarmupTargets() []ReaderWarmupTarget
}
ReaderWarmupTargeter exposes reader-owned warmup targets after compilation.
type ReportOrdering ¶ added in v1.1.0
type ReportOrdering struct {
// contains filtered or unexported fields
}
ReportOrdering is a trusted, invocation-local permission, not a selector or transport input. It changes only the ordering gate; SQL validation still runs.
func ForwardReportOrdering ¶ added in v1.1.0
func ForwardReportOrdering(ctx context.Context, target ComponentTarget, view string) *ReportOrdering
ForwardReportOrdering explicitly delegates the current report permission to a handler's designated reader. Ordinary handler calls have nothing to forward. Supplying this value on another target's request is rejected by runtime.
func NewReportOrdering ¶ added in v1.1.0
func NewReportOrdering(target ComponentTarget, view string, fields ...string) *ReportOrdering
NewReportOrdering is for server-side report adapters targeting an exact route. Fields are selected scalar identities, not hidden relation dependencies. An empty set permits no ordering columns. SQL resolves and validates these names.