mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 10:26:30 +00:00
at least it compiles
This commit is contained in:
65
src/main.rs
65
src/main.rs
@@ -28,13 +28,13 @@ extern crate log;
|
||||
extern crate md5;
|
||||
extern crate num_cpus;
|
||||
extern crate once_cell;
|
||||
extern crate rustls_pemfile;
|
||||
extern crate serde;
|
||||
extern crate serde_derive;
|
||||
extern crate sqlparser;
|
||||
extern crate tokio;
|
||||
extern crate toml;
|
||||
extern crate tokio_rustls;
|
||||
extern crate rustls_pemfile;
|
||||
extern crate toml;
|
||||
|
||||
use log::{debug, error, info};
|
||||
use parking_lot::Mutex;
|
||||
@@ -45,6 +45,11 @@ use tokio::{
|
||||
sync::mpsc,
|
||||
};
|
||||
|
||||
use tokio::net::{
|
||||
tcp::{OwnedReadHalf, OwnedWriteHalf},
|
||||
TcpStream,
|
||||
};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -62,6 +67,7 @@ mod sharding;
|
||||
mod stats;
|
||||
mod stream;
|
||||
|
||||
use crate::constants::*;
|
||||
use config::{get_config, reload_config};
|
||||
use pool::{ClientServerMap, ConnectionPool};
|
||||
use stats::{Collector, Reporter, REPORTER};
|
||||
@@ -153,32 +159,45 @@ async fn main() {
|
||||
// Handle client.
|
||||
tokio::task::spawn(async move {
|
||||
let start = chrono::offset::Utc::now().naive_utc();
|
||||
match client::Client::startup(socket, client_server_map).await {
|
||||
Ok(mut client) => {
|
||||
info!("Client {:?} connected", addr);
|
||||
|
||||
match client.handle().await {
|
||||
Ok(()) => {
|
||||
let duration = chrono::offset::Utc::now().naive_utc() - start;
|
||||
|
||||
info!(
|
||||
"Client {:?} disconnected, session duration: {}",
|
||||
addr,
|
||||
format_duration(&duration)
|
||||
);
|
||||
}
|
||||
|
||||
Err(err) => {
|
||||
error!("Client disconnected with error: {:?}", err);
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
// match client::get_startup(&mut socket) {
|
||||
// Ok((code, bytes)) => match code {
|
||||
// SSL_REQUEST_CODE => client::Client::tls_startup<
|
||||
// }
|
||||
// }
|
||||
|
||||
match client::client_loop(socket, client_server_map).await {
|
||||
Ok(_) => (),
|
||||
Err(err) => {
|
||||
debug!("Client failed to login: {:?}", err);
|
||||
}
|
||||
};
|
||||
|
||||
// match client::Client::<OwnedReadHalf, OwnedWriteHalf>::startup(socket, client_server_map).await {
|
||||
// Ok(mut client) => {
|
||||
// info!("Client {:?} connected", addr);
|
||||
|
||||
// match client.handle().await {
|
||||
// Ok(()) => {
|
||||
// let duration = chrono::offset::Utc::now().naive_utc() - start;
|
||||
|
||||
// info!(
|
||||
// "Client {:?} disconnected, session duration: {}",
|
||||
// addr,
|
||||
// format_duration(&duration)
|
||||
// );
|
||||
// }
|
||||
|
||||
// Err(err) => {
|
||||
// error!("Client disconnected with error: {:?}", err);
|
||||
// client.release();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Err(err) => {
|
||||
// debug!("Client failed to login: {:?}", err);
|
||||
// }
|
||||
// };
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user