MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / invoke_remote

Method invoke_remote

crates/cargo-lambda-invoke/src/lib.rs:179–215  ·  view source on GitHub ↗
(&self, data: &str)

Source from the content-addressed store, hash-verified

177 }
178
179 async fn invoke_remote(&self, data: &str) -> Result<String> {
180 if self.function_name == DEFAULT_PACKAGE_FUNCTION {
181 return Err(InvokeError::InvalidFunctionName.into());
182 }
183
184 let client_context = self.client_context(true)?;
185
186 let sdk_config = self.remote_config.sdk_config(None).await;
187 let client = LambdaClient::new(&sdk_config);
188
189 let resp = client
190 .invoke()
191 .function_name(&self.function_name)
192 .set_qualifier(self.remote_config.alias.clone())
193 .payload(Blob::new(data.as_bytes()))
194 .set_client_context(client_context)
195 .send()
196 .await
197 .into_diagnostic()
198 .wrap_err("failed to invoke remote function")?;
199
200 if let Some(payload) = resp.payload {
201 let blob = payload.into_inner();
202 let data = from_utf8(&blob)
203 .into_diagnostic()
204 .wrap_err("failed to read response payload")?;
205
206 if resp.function_error.is_some() {
207 let err = RemoteInvokeError::try_from(data)?;
208 Err(err.into())
209 } else {
210 Ok(data.into())
211 }
212 } else {
213 Ok("OK".into())
214 }
215 }
216
217 async fn invoke_local(&self, data: &str) -> Result<String> {
218 let host = parse_invoke_ip_address(&self.invoke_address)?;

Callers 1

runMethod · 0.80

Calls 4

newFunction · 0.85
client_contextMethod · 0.80
sdk_configMethod · 0.80
invokeMethod · 0.80

Tested by

no test coverage detected