MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / dispatch_prpc

Function dispatch_prpc

ra-rpc/src/lib.rs:85–102  ·  view source on GitHub ↗
(
    path: String,
    data: Vec<u8>,
    json: bool,
    query: bool,
    server: impl PrpcService + Send + 'static,
)

Source from the content-addressed store, hash-verified

83}
84
85async fn dispatch_prpc(
86 path: String,
87 data: Vec<u8>,
88 json: bool,
89 query: bool,
90 server: impl PrpcService + Send + 'static,
91) -> (u16, Vec<u8>) {
92 info!("dispatching request: {path}");
93 let result = server.dispatch_request(&path, data, json, query).await;
94 let (code, data) = match result {
95 Ok(data) => (200, data),
96 Err(err) => {
97 error!("rpc error: {err:?}");
98 (400, encode_error(json, &err))
99 }
100 };
101 (code, data)
102}
103
104pub fn encode_error(json: bool, error: &impl Display) -> Vec<u8> {
105 let error = format!("{error:#}");

Callers 1

callMethod · 0.85

Calls 1

encode_errorFunction · 0.85

Tested by

no test coverage detected