mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 10:26:30 +00:00
it works!
This commit is contained in:
28
src/main.rs
28
src/main.rs
@@ -1,11 +1,13 @@
|
||||
extern crate bytes;
|
||||
extern crate md5;
|
||||
extern crate tokio;
|
||||
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
mod client;
|
||||
mod errors;
|
||||
mod messages;
|
||||
mod client;
|
||||
mod server;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -30,13 +32,29 @@ async fn main() {
|
||||
|
||||
// Client goes to another thread, bye.
|
||||
tokio::task::spawn(async move {
|
||||
println!(">> Client {:?} connected", addr);
|
||||
println!(">> Client {:?} connected.", addr);
|
||||
|
||||
match client::Client::startup(socket).await {
|
||||
Ok(mut client) => {
|
||||
println!(">> Client {:?} connected successfully!", addr);
|
||||
client.handle().await;
|
||||
},
|
||||
println!(">> Client {:?} authenticated successfully!", addr);
|
||||
let server =
|
||||
match server::Server::startup("127.0.0.1", "5432", "lev", "lev", "lev")
|
||||
.await
|
||||
{
|
||||
Ok(server) => server,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
match client.handle(server).await {
|
||||
Ok(()) => {
|
||||
println!(">> Client {:?} disconnected.", addr);
|
||||
}
|
||||
|
||||
Err(err) => {
|
||||
println!(">> Client disconnected with error: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(err) => {
|
||||
println!(">> Error: {:?}", err);
|
||||
|
||||
Reference in New Issue
Block a user