Skip to main content

FraiseWireAdapter

Struct FraiseWireAdapter 

Source
pub struct FraiseWireAdapter { /* private fields */ }
Expand description

The wire backend, behind the same feature that gates it in fraiseql-db. FraiseQL-Wire database adapter.

Uses fraiseql-wire for streaming JSON queries with bounded memory usage. This adapter is optimized for read-heavy workloads with large result sets.

§Streaming reads

This adapter inherits the trait’s buffering default for stream_with_projection, so its rows are correct but materialised — the same shape the collecting methods below already have. That is a deliberate non-implementation, not an oversight: the underlying QueryStream really does stream, and threading it through would be a small change, but no CI leg executes this adapter against a real database, so the result could not be proven — only compiled. See #1115.

§Architecture

  • Connection Factory: Creates fresh clients on demand
  • Streaming: Results are streamed incrementally (O(chunk_size) memory)
  • WHERE Translation: AST → SQL via WhereSqlGenerator

§Example

ⓘ
use fraiseql_core::db::{FraiseWireAdapter, WhereClause, WhereOperator, DatabaseAdapter};
use serde_json::json;

// Create adapter
let adapter = FraiseWireAdapter::new("postgres://localhost/mydb");

// Build WHERE clause
let where_clause = WhereClause::Field {
    path: vec!["status".to_string()],
    operator: WhereOperator::Eq,
    value: json!("active"),
};

// Execute query
let results = adapter
    .execute_where_query("v_user", Some(&where_clause), Some(10), None, None)
    .await?;

println!("Found {} users", results.len());

Implementations§

Source§

impl FraiseWireAdapter

Source

pub fn new(connection_string: impl Into<String>) -> FraiseWireAdapter

Create a new FraiseWire adapter.

§Arguments
  • connection_string - PostgreSQL connection string
§Example
ⓘ
use fraiseql_core::db::FraiseWireAdapter;

let adapter = FraiseWireAdapter::new("postgres://localhost/fraiseql");
Source

pub const fn with_chunk_size(self, chunk_size: usize) -> FraiseWireAdapter

Set chunk size for streaming queries.

Larger chunk sizes increase throughput but use more memory. Smaller chunk sizes reduce memory usage but may decrease throughput.

§Arguments
  • chunk_size - Number of rows per chunk (default: 1024)
§Example
ⓘ
use fraiseql_core::db::FraiseWireAdapter;

let adapter = FraiseWireAdapter::new("postgres://localhost/fraiseql")
    .with_chunk_size(512);

Trait Implementations§

Source§

impl Clone for FraiseWireAdapter

Source§

fn clone(&self) -> FraiseWireAdapter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DatabaseAdapter for FraiseWireAdapter

Source§

fn execute_with_projection<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, view: &'life1 str, _projection: Option<&'life2 SqlProjectionHint>, where_clause: Option<&'life3 WhereClause>, limit: Option<u32>, offset: Option<u32>, order_by: Option<&'life4 [OrderByClause]>, ) -> Pin<Box<dyn Future<Output = Result<Vec<JsonbValue>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, FraiseWireAdapter: 'async_trait,

§Errors

Returns FraiseQLError::Database if the wire connection or query execution fails.

Source§

fn execute_where_query<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, view: &'life1 str, where_clause: Option<&'life2 WhereClause>, limit: Option<u32>, offset: Option<u32>, order_by: Option<&'life3 [OrderByClause]>, ) -> Pin<Box<dyn Future<Output = Result<Vec<JsonbValue>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, FraiseWireAdapter: 'async_trait,

§Errors

Returns FraiseQLError::Validation if SQL generation fails, or FraiseQLError::Database if the wire connection or query execution fails.

Source§

fn supports_composed_reads(&self) -> bool

Stated rather than inherited, with the reason: a composed read carries every embedded level’s RLS predicate in its WHERE, and this adapter binds no parameters — it escapes values into literal SQL. Composing here would run authorization predicates through string escaping; binding parameters comes first.

Source§

fn execute_raw_query<'life0, 'life1, 'async_trait>( &'life0 self, _sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FraiseWireAdapter: 'async_trait,

§Errors

Always returns FraiseQLError::Database — arbitrary SQL is not supported by fraiseql-wire; use Self::execute_where_query instead.

Source§

fn execute_parameterized_aggregate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _sql: &'life1 str, _params: &'life2 [Value], ) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, FraiseWireAdapter: 'async_trait,

§Errors

Always returns FraiseQLError::Database — aggregate SQL is not supported by fraiseql-wire.

Source§

fn database_type(&self) -> DatabaseType

Get database type (for logging/metrics). Read more
Source§

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FraiseWireAdapter: 'async_trait,

Health check - verify database connectivity. Read more
Source§

fn pool_metrics(&self) -> PoolMetrics

Get connection pool metrics. Read more
Source§

fn query_stats<'life0, 'async_trait>( &'life0 self, _limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<QueryStatEntry>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FraiseWireAdapter: 'async_trait,

Retrieve query performance statistics from the database. Read more
Source§

fn query_stats_by_id<'life0, 'life1, 'async_trait>( &'life0 self, _id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<QueryStatEntry>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FraiseWireAdapter: 'async_trait,

Retrieve statistics for a single query by its ID. Read more
Source§

fn execute_where_query_arc<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, view: &'life1 str, where_clause: Option<&'life2 WhereClause>, limit: Option<u32>, offset: Option<u32>, order_by: Option<&'life3 [OrderByClause]>, ) -> Pin<Box<dyn Future<Output = Result<Arc<Vec<JsonbValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Like execute_where_query but returns the result wrapped in an Arc. Read more
Source§

fn execute_with_projection_arc<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, request: &'life1 ProjectionRequest<'life2>, ) -> Pin<Box<dyn Future<Output = Result<Arc<Vec<JsonbValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Like execute_with_projection but returns the result wrapped in an Arc. Read more
Source§

fn serves_reads_from_standbys(&self) -> bool

Whether reads may be served by a hot standby — read replicas are configured (#1390). Read more
Source§

fn execute_row_query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, view_name: &'life1 str, columns: &'life2 [ColumnSpec], where_sql: Option<&'life3 str>, order_by: Option<&'life4 str>, limit: Option<u32>, offset: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<ColumnValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Execute a row-shaped query against a view, returning typed column values. Read more
Source§

fn execute_row_query_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'life7, 'async_trait>( &'life0 self, view_name: &'life1 str, columns: &'life2 [ColumnSpec], where_sql: Option<&'life3 str>, order_by: Option<&'life4 str>, limit: Option<u32>, offset: Option<u32>, _session_vars: &'life5 [(&'life6 str, &'life7 str)], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<ColumnValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, 'life6: 'async_trait, 'life7: 'async_trait, Self: 'async_trait,

Connection-affine variant of execute_row_query. Read more
Source§

fn execute_parameterized_aggregate_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, sql: &'life1 str, params: &'life2 [Value], _session_vars: &'life3 [(&'life4 str, &'life5 str)], _routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Connection-affine variant of execute_parameterized_aggregate. Read more
Source§

fn invalidate_views<'life0, 'life1, 'async_trait>( &'life0 self, _views: &'life1 [ViewName], ) -> Pin<Box<dyn Future<Output = Result<u64, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Invalidate cached query results for the specified views. Read more
Source§

fn invalidate_by_entity<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _entity_type: &'life1 str, _entity_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<u64, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Evict cache entries that contain the given entity UUID. Read more
Source§

fn result_cache_stats(&self) -> Option<ResultCacheStats>

A snapshot of this adapter’s query-result cache, or None if it has none. Read more
Source§

fn clear_result_cache<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<usize>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Drop every entry in this adapter’s query-result cache. Read more
Source§

fn explain_query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _sql: &'life1 str, _params: &'life2 [Value], ) -> Pin<Box<dyn Future<Output = Result<Value, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Run the database’s EXPLAIN on a SQL statement without executing it. Read more
Source§

fn explain_where_query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _view: &'life1 str, _where_clause: Option<&'life2 WhereClause>, _limit: Option<u32>, _offset: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Value, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Run EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) against a view with the same parameterized WHERE clause that execute_where_query would use. Read more
Source§

fn execute_where_query_arc_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>( &'life0 self, view: &'life1 str, where_clause: Option<&'life2 WhereClause>, limit: Option<u32>, offset: Option<u32>, order_by: Option<&'life3 [OrderByClause]>, _session_vars: &'life4 [(&'life5 str, &'life6 str)], _routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<Arc<Vec<JsonbValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, 'life6: 'async_trait, Self: 'async_trait,

Connection-affine variant of execute_where_query_arc. Read more
Source§

fn count_where_query<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, view: &'life1 str, where_clause: Option<&'life2 WhereClause>, session_vars: &'life3 [(&'life4 str, &'life5 str)], routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<u64, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Count the rows of view matching where_clause, without materialising them. Read more
Source§

fn execute_with_projection_arc_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, request: &'life1 ProjectionRequest<'life2>, _session_vars: &'life3 [(&'life4 str, &'life5 str)], _routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<Arc<Vec<JsonbValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Connection-affine variant of execute_with_projection_arc. Read more
Source§

fn stream_with_projection<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, request: &'life1 ProjectionRequest<'life2>, session_vars: &'life3 [(&'life4 str, &'life5 str)], routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<JsonbValue, FraiseQLError>> + Send>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

The same read as execute_with_projection_arc_with_session, delivered row by row instead of as a materialised Vec (#958). Read more
Source§

fn execute_composed_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, read: &'life1 ComposedLevel, _session_vars: &'life2 [(&'life3 str, &'life4 str)], _routing: ReadRouting, ) -> Pin<Box<dyn Future<Output = Result<Arc<Vec<JsonbValue>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Execute a read that composes its embedded levels into one statement. Read more
Source§

fn stream_row_query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, view_name: &'life1 str, columns: &'life2 [ColumnSpec], where_sql: Option<&'life3 str>, order_by: Option<&'life4 str>, limit: Option<u32>, offset: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Vec<ColumnValue>, FraiseQLError>> + Send>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

The same read as execute_row_query, delivered row by row (#958). Read more
Source§

fn stream_row_query_with_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'life7, 'async_trait>( &'life0 self, view_name: &'life1 str, columns: &'life2 [ColumnSpec], where_sql: Option<&'life3 str>, order_by: Option<&'life4 str>, limit: Option<u32>, offset: Option<u32>, _session_vars: &'life5 [(&'life6 str, &'life7 str)], ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Vec<ColumnValue>, FraiseQLError>> + Send>>, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, 'life6: 'async_trait, 'life7: 'async_trait, Self: 'async_trait,

Connection-affine variant of stream_row_query. Read more
Source§

fn reset_query_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Reset query performance statistics. Read more
Source§

fn on_schema_reload(&self)

Notify the adapter that the schema has changed. Read more
Source§

fn execute_admin_sql<'life0, 'life1, 'async_trait>( &'life0 self, _request: &'life1 AdminSqlRequest, ) -> Pin<Box<dyn Future<Output = Result<AdminSqlOutcome, FraiseQLError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Run one operator-supplied statement under the bounds in request (#962). Read more
Source§

impl Debug for FraiseWireAdapter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more