aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 11:06:46 +01:00
parent df99318392
commit 86e7c72e5f
10383 changed files with 749164 additions and 749170 deletions

View File

@@ -0,0 +1,43 @@
//! Cancels connection work when its executor's proxy scope ends, including HTTP upgrades.
use rama_core::Service;
use rama_core::extensions::ExtensionsRef;
use rama_core::rt::Executor;
#[derive(Clone)]
pub(crate) struct CancelOnShutdown<S> {
inner: S,
}
impl<S> CancelOnShutdown<S> {
pub(crate) fn new(inner: S) -> Self {
Self { inner }
}
}
impl<S, Request> Service<Request> for CancelOnShutdown<S>
where
S: Service<Request, Output = ()>,
Request: ExtensionsRef + Send + 'static,
{
type Output = ();
type Error = S::Error;
async fn serve(&self, request: Request) -> Result<(), Self::Error> {
let guard = request
.extensions()
.get::<Executor>()
.and_then(Executor::guard)
.cloned();
match guard {
Some(guard) => {
tokio::select! {
biased;
_ = guard.cancelled() => Ok(()),
result = self.inner.serve(request) => result,
}
}
None => self.inner.serve(request).await,
}
}
}