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

Method new

lambda-runtime/src/runtime.rs:106–124  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
127impl<S> Runtime<S> {

Callers

nothing calls this directly

Calls 5

max_concurrency_from_envFunction · 0.85
wrap_handlerFunction · 0.85
buildMethod · 0.80
with_pool_sizeMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected