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

Method send_rpc_request

sdk/rust/src/dstack_client.rs:92–127  ·  view source on GitHub ↗
(
        &self,
        path: &str,
        payload: &S,
    )

Source from the content-addressed store, hash-verified

90 }
91
92 async fn send_rpc_request<S: Serialize, D: DeserializeOwned>(
93 &self,
94 path: &str,
95 payload: &S,
96 ) -> anyhow::Result<D> {
97 match &self.client {
98 ClientKind::Http => {
99 let client = Client::new();
100 let url = format!(
101 "{}/{}",
102 self.base_url.trim_end_matches('/'),
103 path.trim_start_matches('/')
104 );
105 let res = client
106 .post(&url)
107 .json(payload)
108 .header("Content-Type", "application/json")
109 .send()
110 .await?
111 .error_for_status()?;
112 Ok(res.json().await?)
113 }
114 ClientKind::Unix => {
115 let mut unix_client = ClientUnix::try_new(&self.endpoint).await?;
116 let res = unix_client
117 .send_request_json::<_, _, Value>(
118 path,
119 Method::POST,
120 &[("Content-Type", "application/json"), ("Host", "dstack")],
121 Some(&payload),
122 )
123 .await?;
124 Ok(res.1)
125 }
126 }
127 }
128
129 pub async fn get_key(
130 &self,

Callers 8

get_keyMethod · 0.45
get_quoteMethod · 0.45
attestMethod · 0.45
infoMethod · 0.45
versionMethod · 0.45
get_tls_keyMethod · 0.45
signMethod · 0.45
verifyMethod · 0.45

Calls 1

sendMethod · 0.80

Tested by

no test coverage detected