mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 02:16:30 +00:00
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:
15
src/main.rs
15
src/main.rs
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user