pub trait Source: Send {
// Required methods
fn export(
&mut self,
request: &ExportRequest<'_>,
sink: &mut dyn BatchSink,
) -> Result<()>;
fn query_scalar(&mut self, sql: &str) -> Result<Option<String>>;
fn type_mappings(
&mut self,
query: &str,
column_overrides: &ColumnOverrides,
) -> Result<Vec<TypeMapping>>;
// Provided methods
fn sample_pressure(&mut self) -> Option<u64> { ... }
fn server_context(&mut self) -> Option<String> { ... }
}Required Methods§
Sourcefn export(
&mut self,
request: &ExportRequest<'_>,
sink: &mut dyn BatchSink,
) -> Result<()>
fn export( &mut self, request: &ExportRequest<'_>, sink: &mut dyn BatchSink, ) -> Result<()>
Execute request.query and stream batches into sink.
fn query_scalar(&mut self, sql: &str) -> Result<Option<String>>
Sourcefn type_mappings(
&mut self,
query: &str,
column_overrides: &ColumnOverrides,
) -> Result<Vec<TypeMapping>>
fn type_mappings( &mut self, query: &str, column_overrides: &ColumnOverrides, ) -> Result<Vec<TypeMapping>>
Return TypeMapping for every column in query without fetching rows.
Used by rivet check --type-report to show the full type provenance
(source native type → RivetType → Arrow type → fidelity) before export.
Implementations execute SELECT * FROM (...) AS _q LIMIT 0 so only
server-side type metadata is transferred.
Provided Methods§
Sourcefn sample_pressure(&mut self) -> Option<u64>
fn sample_pressure(&mut self) -> Option<u64>
Sample a monotonic source-pressure counter for the OPT-2 concurrency
governor (pipeline::chunked::exec).
Higher = more pressure. The governor compares successive samples
(cur > prev ⇒ under pressure) — the same convention the adaptive
batch-size loop already uses. Returns None when the engine can’t
cheaply sample a pressure proxy, in which case the governor holds
parallelism flat. Default: None.
Sourcefn server_context(&mut self) -> Option<String>
fn server_context(&mut self) -> Option<String>
A best-effort JSON snapshot of the source SERVER’s forensic context —
version + the limits/session settings that shape failures (the
statement-timeout that surfaces as ERROR 3024, the sql_mode/timezone that
shape text rendering). Captured ONCE at run open onto the failed
export_metrics row (server_context_json), so a post-mortem can explain a
failure without re-querying a possibly-transient server. None when the
engine can’t cheaply gather it; never fails the run.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".