Documentation
¶
Overview ¶
Package api defines implementation-independent contracts for compiling, executing, and debugging Ferret queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Location ¶
Location represents the location of a specific point in a source file, including the file name and position.
type OptimizationLevel ¶
type OptimizationLevel int
const ( OptimizationNone OptimizationLevel = iota OptimizationBasic OptimizationFull OptimizationAggressive )
type Output ¶
Output is the encoded result returned from session or runtime execution. Execution returns a pointer: nil means no output was produced, while a non-nil pointer to a zero-valued Output still represents produced output.
type Plan ¶
type Plan interface {
io.Closer
Params() ([]string, error)
NewSession(ctx context.Context, opts ...SessionOption) (Session, error)
NewDebugSession(ctx context.Context, opts ...SessionOption) (debugger.Session, error)
}
Plan represents a compiled program. Compilation finishes before a plan is returned. Plans support independent sessions and are not consumed by execution. Params returns a caller-owned snapshot or an error if metadata cannot be retrieved.
Close releases plan-owned resources and prevents subsequent session and debug-session creation. It is idempotent and retains its cleanup result, without requiring identical error-wrapper pointers. Close need not wait for constructors already started. It does not implicitly close or cancel returned sessions or debug sessions; callers remain responsible for their lifecycle.
NewSession and NewDebugSession use non-nil caller contexts for cancellation. Close does not cancel those contexts. Callers coordinate work and cleanup when sessions use plan-owned resources.
type PlanOption ¶
type PlanOption = func(PlanOptions) error
func WithOptimizationLevel ¶
func WithOptimizationLevel(level OptimizationLevel) PlanOption
WithOptimizationLevel sets the optimization level for the execution plan. The callback rejects unknown enum values before invoking the target setter; the runtime determines which known levels it supports.
type PlanOptions ¶
type PlanOptions interface {
SetOptimizationLevel(OptimizationLevel) error
}
type Position ¶
Position represents a specific point in a source file, defined by line and column numbers.
type Range ¶
Range represents a range of characters in a source file, including the location and span.
type Runtime ¶
type Runtime interface {
io.Closer
// Run returns nil output with an error when no output was produced.
// A non-nil output with a nil error indicates success, including empty output.
// A non-nil output may accompany an error from cleanup or other processing;
// callers must inspect output independently of the error.
Run(ctx context.Context, src Source, opts ...SessionOption) (*Output, error)
Compile(ctx context.Context, src Source, opts ...PlanOption) (Plan, error)
CompileDebug(ctx context.Context, src Source, opts ...PlanOption) (Plan, error)
}
Runtime compiles source into reusable plans. Callers own directly created plans and sessions and are responsible for their cleanup.
Close releases implementation-owned resources and is idempotent, retaining its cleanup result without requiring identical error-wrapper pointers. Owning runtimes reject subsequent work according to their closed-state semantics. Borrowing adapters may document a no-op Close that leaves the adapter and underlying runtime usable. Close does not implicitly cancel caller-owned work and need not wait for operations already started.
Run, Compile, and CompileDebug use non-nil caller contexts for cancellation. Callers coordinate work and cleanup when descendants use parent-owned resources. Run closes its temporary session and plan, preserving execution and cleanup errors together with any available encoded output.
type Session ¶
type Session interface {
io.Closer
// Run returns nil output with an error when no output was produced.
// A non-nil output with a nil error indicates success, including empty output.
// A non-nil output may accompany an error from cleanup or other processing;
// callers must inspect output independently of the error.
Run(c context.Context) (*Output, error)
}
Session executes a compiled plan with per-session configuration. Run observes its non-nil context and returns caller-owned encoded output. Unless documented otherwise, callers serialize Run and settle it before Close. Close is idempotent and retains its cleanup result, without requiring identical error-wrapper pointers.
type SessionOption ¶
type SessionOption = func(SessionOptions) error
SessionOption applies portable or application-specific session configuration. Implementations invoke non-nil callbacks once in order and join their returned errors. Callbacks may return errors immediately; runtime-specific validation may instead fail in the operation that uses the setting. See SessionOptions.
func WithFSRoot ¶
func WithFSRoot(root string) SessionOption
WithFSRoot selects the rooted filesystem used by one execution session. The runtime defines path validation and owns any filesystem resources created for the session. Validation and construction may occur when the root is applied.
func WithOutputContentType ¶
func WithOutputContentType(contentType string) SessionOption
WithOutputContentType selects the output codec content type for session results. Codec availability may be checked when output is encoded, after query execution.
func WithParam ¶
func WithParam(key string, value any) SessionOption
WithParam sets a session parameter for the execution. The runtime owns conversion and validation of the host value.
func WithParams ¶
func WithParams(params map[string]any) SessionOption
WithParams merges the provided parameter map into the session environment, overriding existing keys while preserving any other previously defined parameters. The runtime defines when values are converted or snapshotted.
type SessionOptions ¶
type SessionOptions interface {
SetParam(string, any) error
SetParams(map[string]any) error
SetOutputContentType(string) error
SetFSRoot(string) error
}
SessionOptions configures a session directly or queues implementation options. Setters may report portable or application-level errors immediately and defer runtime-specific conversion and validation until the setting is used. A nil setter error does not certify that the runtime can use the value.
Invalid settings must fail the operation no later than their relevant point of use. Validation need not precede compilation, resource acquisition, or all query execution. Output codec availability may be checked during result encoding, after the query has run. Implementations document validation and mutable-input conversion or snapshot timing.
Later setters override earlier values; SetParams merges keys. Runtime-specific options reject incompatible targets.
type Source ¶
Source represents the input data for a Ferret query.
func NewAnonymousSource ¶
NewAnonymousSource creates a new anonymous Source instance with the given content.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package debugger defines portable contracts and values for controlling and inspecting Ferret debug sessions, including events, breakpoints, frames, and values.
|
Package debugger defines portable contracts and values for controlling and inspecting Ferret debug sessions, including events, breakpoints, frames, and values. |
|
Package diagnostics defines the portable structured reporting model shared by Ferret runtimes and tooling.
|
Package diagnostics defines the portable structured reporting model shared by Ferret runtimes and tooling. |
|
Package result defines portable encoded outputs returned by Ferret query execution.
|
Package result defines portable encoded outputs returned by Ferret query execution. |
|
Package source defines portable Ferret source inputs and coordinates.
|
Package source defines portable Ferret source inputs and coordinates. |