at least it compiles

This commit is contained in:
Lev
2022-06-27 15:52:01 -07:00
parent b974aacd71
commit eb58920870
5 changed files with 538 additions and 323 deletions

View File

@@ -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);
// }
// };
});
}
});