feat: add integrations

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-03-08 23:00:14 +01:00
parent 5a5f9a3003
commit 646581ff44
65 changed files with 7774 additions and 127 deletions

View File

@@ -0,0 +1,36 @@
use std::net::SocketAddr;
use notmad::{Component, ComponentInfo, MadError};
use tokio_util::sync::CancellationToken;
use crate::state::AppState;
pub struct ServeHttp {
pub addr: SocketAddr,
pub state: AppState,
}
impl Component for ServeHttp {
fn info(&self) -> ComponentInfo {
"forage/http".into()
}
async fn run(&self, cancellation_token: CancellationToken) -> Result<(), MadError> {
let app = crate::build_router(self.state.clone());
let listener = tokio::net::TcpListener::bind(self.addr)
.await
.map_err(|e| MadError::Inner(e.into()))?;
tracing::info!("listening on {}", self.addr);
axum::serve(listener, app)
.with_graceful_shutdown(async move {
cancellation_token.cancelled().await;
})
.await
.map_err(|e| MadError::Inner(e.into()))?;
Ok(())
}
}