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
routemust 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§
Sourcefn route(&self, sql: &str) -> QueryTarget
fn route(&self, sql: &str) -> QueryTarget
Classify sql and return the engine that should execute it.