@@ -102,7 +102,7 @@ use std::{
102102} ;
103103
104104mod streaming;
105- #[ cfg( feature = "experimental- concurrency" ) ]
105+ #[ cfg( feature = "concurrency-tokio " ) ]
106106pub use streaming:: run_with_streaming_response_concurrent;
107107pub use streaming:: { run_with_streaming_response, StreamAdapter } ;
108108
@@ -211,11 +211,17 @@ where
211211/// converting the result into a `LambdaResponse`.
212212///
213213/// # Managed concurrency
214- /// If `AWS_LAMBDA_MAX_CONCURRENCY` is set, this function returns an error because
215- /// it does not enable concurrent polling. If your handler can satisfy `Clone`,
216- /// prefer [`run_concurrent`] (requires the `experimental- concurrency` feature),
214+ /// If `AWS_LAMBDA_MAX_CONCURRENCY` is set, a warning is logged.
215+ /// If your handler can satisfy `Clone + Send + 'static `,
216+ /// prefer [`run_concurrent`] (requires the `concurrency-tokio ` feature),
217217/// which honors managed concurrency and falls back to sequential behavior when
218218/// unset.
219+ ///
220+ /// # Panics
221+ ///
222+ /// This function panics if required Lambda environment variables are missing
223+ /// (`AWS_LAMBDA_FUNCTION_NAME`, `AWS_LAMBDA_FUNCTION_MEMORY_SIZE`,
224+ /// `AWS_LAMBDA_FUNCTION_VERSION`, `AWS_LAMBDA_RUNTIME_API`).
219225pub async fn run < ' a , R , S , E > ( handler : S ) -> Result < ( ) , Error >
220226where
221227 S : Service < Request , Response = R , Error = E > ,
@@ -226,18 +232,29 @@ where
226232 lambda_runtime:: run ( Adapter :: from ( handler) ) . await
227233}
228234
229- /// Starts the Lambda Rust runtime in a mode that is compatible with
230- /// Lambda Managed Instances (concurrent invocations).
235+ /// Starts the Lambda Rust runtime and begins polling for events on the [Lambda
236+ /// Runtime APIs](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html).
237+ ///
238+ /// This takes care of transforming the LambdaEvent into a [`Request`] and then
239+ /// converting the result into a `LambdaResponse`.
231240///
232- /// Requires the `experimental- concurrency` feature.
241+ /// # Managed concurrency
233242///
234243/// When `AWS_LAMBDA_MAX_CONCURRENCY` is set to a value greater than 1, this
235- /// will spawn `AWS_LAMBDA_MAX_CONCURRENCY` worker tasks, each running its own
236- /// `/next` polling loop. When the environment variable is unset or `<= 1`,
237- /// it falls back to the same sequential behavior as [`run`], so the same
238- /// handler can run on both classic Lambda and Lambda Managed Instances.
239- #[ cfg( feature = "experimental-concurrency" ) ]
240- #[ cfg_attr( docsrs, doc( cfg( feature = "experimental-concurrency" ) ) ) ]
244+ /// function spawns multiple tokio worker tasks to handle concurrent invocations.
245+ /// When the environment variable is unset or `<= 1`, it falls back to
246+ /// sequential behavior, so the same handler can run on both classic Lambda
247+ /// and Lambda Managed Instances.
248+ ///
249+ /// # Panics
250+ ///
251+ /// This function panics if:
252+ /// - Called outside of a Tokio runtime with `AWS_LAMBDA_MAX_CONCURRENCY > 1`
253+ /// - Required Lambda environment variables are missing (`AWS_LAMBDA_FUNCTION_NAME`,
254+ /// `AWS_LAMBDA_FUNCTION_MEMORY_SIZE`, `AWS_LAMBDA_FUNCTION_VERSION`,
255+ /// `AWS_LAMBDA_RUNTIME_API`)
256+ #[ cfg( feature = "concurrency-tokio" ) ]
257+ #[ cfg_attr( docsrs, doc( cfg( feature = "concurrency-tokio" ) ) ) ]
241258pub async fn run_concurrent < R , S , E > ( handler : S ) -> Result < ( ) , Error >
242259where
243260 S : Service < Request , Response = R , Error = E > + Clone + Send + ' static ,
0 commit comments