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

Function request

atomic-cli/src/commands/agent/owner.rs:864–893  ·  view source on GitHub ↗

Send one request to an already-running owner.

(repository: &Path, request_body: OwnerRequest)

Source from the content-addressed store, hash-verified

862
863/// Send one request to an already-running owner.
864fn request(repository: &Path, request_body: OwnerRequest) -> anyhow::Result<OwnerResponse> {
865 let dot_dir = Repository::canonical_dot_dir(repository)?;
866 let endpoint = endpoint_name(&dot_dir);
867 let frame = RequestFrame {
868 version: PROTOCOL_VERSION,
869 request_id: Uuid::new_v4().to_string(),
870 request: request_body,
871 };
872 let response = runtime()?.block_on(exchange(&endpoint, &frame))?;
873 if response.version != PROTOCOL_VERSION {
874 return Err(anyhow!(
875 "database owner protocol mismatch: client {}, server {}",
876 PROTOCOL_VERSION,
877 response.version
878 ));
879 }
880 if response.request_id != frame.request_id {
881 return Err(anyhow!(
882 "database owner response request id mismatch: sent {}, received {}",
883 frame.request_id,
884 response.request_id
885 ));
886 }
887 match response.response {
888 OwnerResponse::Error { code, message } => {
889 Err(anyhow!("database owner request failed [{code}]: {message}"))
890 }
891 response => Ok(response),
892 }
893}
894
895fn serve(repository: &Path) -> CliResult<()> {
896 let dot_dir = Repository::canonical_dot_dir(repository)?;

Callers 4

runMethod · 0.70
start_or_reconnectFunction · 0.70
request_with_reconnectFunction · 0.70

Calls 3

endpoint_nameFunction · 0.85
runtimeFunction · 0.85
exchangeFunction · 0.85