Comments (7)
Could you give an example of how this would be used?
Would you want the Lambda function to return early while work happens in the background?
from aws-lambda-java-libs.
Closing awaiting more information.
from aws-lambda-java-libs.
Would you want the Lambda function to return early while work happens in the background?
The point is to avoid blocking a thread when responding to a request.
I've detailed out the motivation in an MS painting:
Kindly reopen this issue, async programming is a feature so basic it's integrated into all modern languages (Javascript, C#, Dart, Swift, Python, Ruby async
, Go chan
, Kotlin suspend
)
Any method that expects to do IO work should be defined as async/suspend e.g.
Kotlin:
suspend fun handleRequest(request: Request): Response {
}
Java:
public Future<Response> handleRequest(Request request) {
}
from aws-lambda-java-libs.
Each execution environment of a Lambda function only handles one request at once.
from aws-lambda-java-libs.
What does that mean? If two requests need to be met at the same time it starts 2 separate processes?
In NodeJs it documenately doesn't work that way:
Node.js initialization
Node.js has a unique event loop model that causes its initialization behavior to be different from other runtimes. Specifically, Node.js uses a non-blocking I/O model that supports asynchronous operations. This model allows Node.js to perform efficiently for most workloads. For example, if a Node.js function makes a network call, that request may be designated as an asynchronous operation and placed into a callback queue. The function may continue to process other operations within the main call stack without getting blocked by waiting for the network call to return. Once the network call is returned, its callback is executed and then removed from the callback queue.
Some initialization tasks may run asynchronously. These asynchronous tasks are not guaranteed to complete execution prior to an invocation. For example, code that makes a network call to fetch a parameter from AWS Parameter Store may not be complete by the time Lambda executes the handler function. As a result, the variable may be null during an invocation. To avoid this, ensure that variables and other asynchronous code are fully initialized before continuing with the rest of the function’s core business logic.
from aws-lambda-java-libs.
If a second invoke of a Lambda function is made before the first has finished a new execution environment will be created.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html
from aws-lambda-java-libs.
I see. As I don't see this model changing, there's no point for an EventHandler to be async.
from aws-lambda-java-libs.
Related Issues (20)
- SnapStart Support HOT 9
- Announcement: default branch renaming
- The field "records" in SQSEvent should be renamed to "Records" HOT 4
- Support Event Step Function HOT 1
- Log issues when using the Quarkus Java framework HOT 6
- Environment variable different when SnapStart is enabled HOT 6
- Simulate AWS runtime environment for lambda in local run. HOT 3
- KinesisEvent not parsed correctly HOT 2
- Incomplete and/or missing API Gateway Lambda Authorizer events HOT 5
- RequestStreamHandler not working as expect HOT 2
- AWS lamba core reactive types HOT 2
- EventLoader unable to correctly deserialize posted json body data for APIGateway events HOT 2
- Failed to serialize CognitoUserPoolPreTokenGenerationEvent HOT 7
- Support VPC Lattice event structure
- APIGatewayProxyRequestEvent$RequestIdentity missing "cognitoAmr" field HOT 2
- Unable to upgrade with newer Jackson - conflicting `com.fasterxml.jackson.annotation.JsonFormat` HOT 5
- SNSEvent Jackson mixins are Incomplete HOT 6
- Failed to deserialize DynamodbEvent.DynamodbStreamRecord#dynamodb HOT 6
- Support v2 of Pre Token Generation Lambda HOT 1
- AWS documentation says LambdaLogger will default to the INFO log level, but it is actually defaulting to UNDEFINED HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-java-libs.