Add buffers

This commit is contained in:
eraden 2023-09-20 10:56:23 +02:00
parent 028966d539
commit da80468266

View File

@ -31,6 +31,8 @@ mod server;
use server::*;
mod error;
use error::*;
mod buffers;
use buffers::*;
#[derive(gumdrop::Options)]
struct Args {
@ -101,6 +103,10 @@ async fn handle_commands(
) {
let mut buf = Vec::with_capacity(server.max_payload);
// use futures::stream::{self, StreamExt};
// let read_stream = futures::stream::unfold(rx, |rx| {
// });
let conn_info = ConnectionInfo {
client_ip: addr.to_string(),
server_id: "asdajsdjasdjas".into(),
@ -184,19 +190,6 @@ async fn read_to_msg_end(rx: &mut OwnedReadHalf, buf: &mut Vec<u8>) -> Option<us
}
}
async fn start_stream_health_check(ctx: Context, dead_notif: Sender<()>) {
const PING_PONG_SPAN: time::Duration = time::Duration::seconds(1);
loop {
if *ctx.last_live_msg.read().await + PING_PONG_SPAN >= OffsetDateTime::now_utc() {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
continue;
} else {
dead_notif.send(()).await.unwrap();
}
break;
}
}
async fn handle_msg<'stream>(
msg: &str,
buf: &mut Vec<u8>,
@ -230,3 +223,16 @@ async fn handle_msg<'stream>(
};
Ok(())
}
async fn start_stream_health_check(ctx: Context, dead_notif: Sender<()>) {
const PING_PONG_SPAN: time::Duration = time::Duration::seconds(1);
loop {
if *ctx.last_live_msg.read().await + PING_PONG_SPAN >= OffsetDateTime::now_utc() {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
continue;
} else {
dead_notif.send(()).await.unwrap();
}
break;
}
}