Refactor query routing into its own module (#22)

* Refactor query routing into its own module

* commments; tests; dead code

* error message

* safer startup

* hm

* dont have to be public

* wow

* fix ci

* ok

* nl

* no more silent errors
This commit is contained in:
Lev Kokotov
2022-02-16 22:52:11 -08:00
committed by GitHub
parent 7b0ceefb96
commit 4c8a3987fe
11 changed files with 364 additions and 144 deletions

View File

@@ -25,7 +25,6 @@ extern crate statsd;
extern crate tokio;
extern crate toml;
use regex::Regex;
use tokio::net::TcpListener;
use tokio::signal;
@@ -39,6 +38,7 @@ mod constants;
mod errors;
mod messages;
mod pool;
mod query_router;
mod server;
mod sharding;
mod stats;
@@ -54,12 +54,11 @@ use stats::{Collector, Reporter};
async fn main() {
println!("> Welcome to PgCat! Meow.");
client::SHARDING_REGEX_RE
.set(Regex::new(client::SHARDING_REGEX).unwrap())
.unwrap();
client::ROLE_REGEX_RE
.set(Regex::new(client::ROLE_REGEX).unwrap())
.unwrap();
// Prepare regexes
if !query_router::QueryRouter::setup() {
println!("> Could not setup query router.");
return;
}
let config = match config::parse("pgcat.toml").await {
Ok(config) => config,