MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / handle_connection

Function handle_connection

atomic-cli/src/commands/agent/owner.rs:1313–1331  ·  view source on GitHub ↗
(
    mut stream: S,
    store: Arc<RedbChangeStore>,
    shutdown: Arc<Notify>,
)

Source from the content-addressed store, hash-verified

1311}
1312
1313async fn handle_connection<S>(
1314 mut stream: S,
1315 store: Arc<RedbChangeStore>,
1316 shutdown: Arc<Notify>,
1317) -> anyhow::Result<()>
1318where
1319 S: AsyncRead + AsyncWrite + Unpin,
1320{
1321 let request: RequestFrame = read_frame(&mut stream).await?;
1322 let (response, should_shutdown) = handle_request(&store, request);
1323 write_frame(&mut stream, &response).await?;
1324 stream.shutdown().await?;
1325 if should_shutdown {
1326 // `notify_one` retains a permit if the accept loop is between polls,
1327 // preventing a shutdown request from being acknowledged but lost.
1328 shutdown.notify_one();
1329 }
1330 Ok(())
1331}
1332
1333async fn read_frame<T, S>(stream: &mut S) -> anyhow::Result<T>
1334where

Callers

nothing calls this directly

Calls 3

read_frameFunction · 0.85
handle_requestFunction · 0.85
write_frameFunction · 0.85

Tested by

no test coverage detected