Query parser 3.0 (#23)

* Starting query parsing

* Query parser

* working config

* disable by default

* fix tsets

* introducing log crate; test for query router; comments

* typo

* fixes for banning

* added test for prepared stmt
This commit is contained in:
Lev Kokotov
2022-02-18 07:10:18 -08:00
committed by GitHub
parent 4c8a3987fe
commit aa796289bf
8 changed files with 296 additions and 75 deletions

View File

@@ -16,11 +16,13 @@
extern crate async_trait;
extern crate bb8;
extern crate bytes;
extern crate log;
extern crate md5;
extern crate num_cpus;
extern crate once_cell;
extern crate serde;
extern crate serde_derive;
extern crate sqlparser;
extern crate statsd;
extern crate tokio;
extern crate toml;
@@ -47,6 +49,7 @@ mod stats;
// secret keys to the backend's.
use config::Role;
use pool::{ClientServerMap, ConnectionPool};
use query_router::QueryRouter;
use stats::{Collector, Reporter};
/// Main!
@@ -118,6 +121,8 @@ async fn main() {
return;
}
};
let primary_reads_enabled = config.query_router.primary_reads_enabled;
let query_parser_enabled = config.query_router.query_parser_enabled;
let server_info = match pool.validate().await {
Ok(info) => info,
@@ -155,7 +160,6 @@ async fn main() {
socket,
client_server_map,
transaction_mode,
default_server_role,
server_info,
reporter,
)
@@ -164,7 +168,14 @@ async fn main() {
Ok(mut client) => {
println!(">> Client {:?} authenticated successfully!", addr);
match client.handle(pool).await {
let query_router = QueryRouter::new(
default_server_role,
pool.shards(),
primary_reads_enabled,
query_parser_enabled,
);
match client.handle(pool, query_router).await {
Ok(()) => {
let duration = chrono::offset::Utc::now().naive_utc() - start;