Skip to main content

run_with_streaming_response_concurrent

Function run_with_streaming_response_concurrent 

Source
pub async fn run_with_streaming_response_concurrent<S, B, E>(
    handler: S,
) -> Result<(), Error>
where S: Service<Request, Response = Response<B>, Error = E> + Clone + Send + 'static, S::Future: Send + 'static, E: Debug + Into<Diagnostic> + Send + 'static, B: Body + Unpin + Send + 'static, B::Data: Into<Bytes> + Send, B::Error: Into<Error> + Send + Debug,
Available on crate feature concurrency-tokio only.
Expand description

Runs the Lambda runtime with a handler that returns streaming HTTP responses, in a mode that is compatible with Lambda Managed Instances.

When AWS_LAMBDA_MAX_CONCURRENCY is set to a value greater than 1, this spawns multiple tokio worker tasks to handle concurrent invocations. When the environment variable is unset or <= 1, it falls back to sequential behavior, so the same handler can run on both classic Lambda and Lambda Managed Instances.

ยงPanics

This function panics if:

  • Called outside of a Tokio runtime
  • Required Lambda environment variables are missing (AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_FUNCTION_MEMORY_SIZE, AWS_LAMBDA_FUNCTION_VERSION, AWS_LAMBDA_RUNTIME_API)