public class AsyncInitializationWrapper extends InitializationWrapper
InitializationWrapper interface. This initializer calls the
LambdaContainerHandler.initialize() in a separate thread. Then uses a latch to wait for the maximum Lambda
initialization time of 10 seconds, if the initialize method takes longer than 10 seconds to return, the
start(LambdaContainerHandler) returns control to the caller and lets the initialization thread continue in
the background. The LambdaContainerHandler.proxy(Object, Context) automatically waits for the latch of the
initializer to be released.
The constructor of this class expects an epoch long. This is meant to be as close as possible to the time the Lambda
function actually started. In most cases, the first action in the constructor of the handler class should be to populate
this long value (Instant.now().toEpochMs();). This class uses the value to estimate how much of the init 10
seconds has already been used up.| Constructor and Description |
|---|
AsyncInitializationWrapper()
Creates a new instance of the async initializer using the actual JVM start time as the starting point to measure
the 10 seconds timeout.
|
AsyncInitializationWrapper(long startTime)
Creates a new instance of the async initializer.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getActualStartTimeMs() |
CountDownLatch |
getInitializationLatch()
Asynchronous implementations of the framework should return a latch that the container handler can use to decide
whether it can start handling events.
|
void |
start(LambdaContainerHandler handler)
This is the main entry point.
|
public AsyncInitializationWrapper(long startTime)
startTime - The epoch ms start time of the Lambda function, this should be measured as close as possible to
the initialization of the function.public AsyncInitializationWrapper()
public void start(LambdaContainerHandler handler) throws ContainerInitializationException
InitializationWrappergetAwsProxyHandler() methods
of the various implementations will call this to initialize the underlying frameworkstart in class InitializationWrapperhandler - The container handler to be initializerContainerInitializationException - If anything goes wrong during container initialization.public long getActualStartTimeMs()
public CountDownLatch getInitializationLatch()
InitializationWrappernull.getInitializationLatch in class InitializationWrapperCopyright © 2022. All rights reserved.