(
service: &mut S,
config: &Arc<Config>,
event: http::Response<hyper::body::Incoming>,
set_amzn_trace_env: bool,
)
| 479 | } |
| 480 | |
| 481 | async 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> |
| 487 | where |
| 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 | |
| 519 | fn amzn_trace_env(ctx: &Context) { |
| 520 | match &ctx.xray_trace_id { |
no test coverage detected