feat: add initial churn

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-25 21:52:28 +02:00
parent f61d0bbf12
commit 97978df287
7 changed files with 258 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
use std::net::SocketAddr;
use axum::{response::IntoResponse, routing::get, Router};
use clap::{Parser, Subcommand};
#[derive(Parser)]
@@ -44,8 +45,16 @@ async fn main() -> anyhow::Result<()> {
async fn handle_command(cmd: Command) -> anyhow::Result<()> {
match cmd.command {
Some(Commands::Daemon { host }) => {
tracing::info!("starting agent server on {}", host);
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
tracing::info!("Starting churn server");
let app = Router::new().route("/ping", get(ping));
tracing::info!("churn server listening on {}", host);
axum::Server::bind(&host)
.serve(app.into_make_service())
.await
.unwrap();
Ok(())
}
Some(Commands::Connect {
@@ -56,3 +65,7 @@ async fn handle_command(cmd: Command) -> anyhow::Result<()> {
None => todo!(),
}
}
async fn ping() -> impl IntoResponse {
"pong!"
}