Create a new runtime that executes the provided handler for incoming requests. In order to start the runtime and poll for events on the [Lambda Runtime APIs](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), you must call [Runtime::run]. Note that manually creating a [Runtime] does not add tracing to the executed handler as is done by [super::run]. If you want to add the default t
(handler: F)
| 104 | /// (`AWS_LAMBDA_FUNCTION_NAME`, `AWS_LAMBDA_FUNCTION_MEMORY_SIZE`, |
| 105 | /// `AWS_LAMBDA_FUNCTION_VERSION`, `AWS_LAMBDA_RUNTIME_API`). |
| 106 | pub fn new(handler: F) -> Self { |
| 107 | trace!("Loading config from env"); |
| 108 | let config = Arc::new(Config::from_env()); |
| 109 | let concurrency_limit = max_concurrency_from_env().unwrap_or(1).max(1); |
| 110 | // Strategy: allocate all worker tasks up-front, so size the client pool to match. |
| 111 | let pool_size = concurrency_limit as usize; |
| 112 | let client = Arc::new( |
| 113 | ApiClient::builder() |
| 114 | .with_pool_size(pool_size) |
| 115 | .build() |
| 116 | .expect("Unable to create a runtime client"), |
| 117 | ); |
| 118 | Self { |
| 119 | service: wrap_handler(handler, client.clone()), |
| 120 | config, |
| 121 | client, |
| 122 | concurrency_limit, |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | impl<S> Runtime<S> { |
nothing calls this directly
no test coverage detected