Skip to main content

QueryRouter

Trait QueryRouter 

Source
pub trait QueryRouter: Send + Sync {
    // Required method
    fn route(&self, sql: &str) -> QueryTarget;
}
Expand description

Classifies SQL statements and routes them to the correct engine.

The default implementation (SqlParserRouter in rhei-sync) parses the SQL AST and applies the following heuristic:

  • Writes (INSERT/UPDATE/DELETE), DDL, and simple point-lookups → OLTP
  • Aggregates, GROUP BY, JOINs, window functions, CTEs, subqueries → OLAP

§Contract for implementors

  • route must be infallible and synchronous (no I/O).
  • When uncertain, prefer QueryTarget::Oltp (safety-first: writes must never accidentally go to the read-only OLAP engine).

Required Methods§

Source

fn route(&self, sql: &str) -> QueryTarget

Classify sql and return the engine that should execute it.

Implementors§