MCPcopy Index your code
hub / github.com/aws/aws-lambda-rust-runtime / process_invocation

Function process_invocation

lambda-runtime/src/runtime.rs:481–517  ·  view source on GitHub ↗
(
    service: &mut S,
    config: &Arc<Config>,
    event: http::Response<hyper::body::Incoming>,
    set_amzn_trace_env: bool,
)

Source from the content-addressed store, hash-verified

479}
480
481async fn process_invocation<S>(
482 service: &mut S,
483 config: &Arc<Config>,
484 event: http::Response<hyper::body::Incoming>,
485 set_amzn_trace_env: bool,
486) -> Result<(), BoxError>
487where
488 S: Service<LambdaInvocation, Response = (), Error = BoxError>,
489{
490 let (parts, incoming) = event.into_parts();
491
492 #[cfg(debug_assertions)]
493 if parts.status == http::StatusCode::NO_CONTENT {
494 // Ignore the event if the status code is 204.
495 // This is a way to keep the runtime alive when
496 // there are no events pending to be processed.
497 return Ok(());
498 }
499
500 // Build the invocation such that it can be sent to the service right away
501 // when it is ready
502 let body = incoming.collect().await?.to_bytes();
503 let context = Context::new(invoke_request_id(&parts.headers)?, config.clone(), &parts.headers)?;
504 let invocation = LambdaInvocation { parts, body, context };
505
506 if set_amzn_trace_env {
507 // Setup Amazon's default tracing data
508 amzn_trace_env(&invocation.context);
509 }
510
511 // Wait for service to be ready
512 let ready = service.ready().await?;
513
514 // Once ready, call the service which will respond to the Lambda runtime API
515 ready.call(invocation).await?;
516 Ok(())
517}
518
519fn amzn_trace_env(ctx: &Context) {
520 match &ctx.xray_trace_id {

Callers 2

run_with_incomingMethod · 0.85
concurrent_worker_loopFunction · 0.85

Calls 7

invoke_request_idFunction · 0.85
amzn_trace_envFunction · 0.85
into_partsMethod · 0.80
collectMethod · 0.80
readyMethod · 0.80
cloneMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected