Giter VIP home page Giter VIP logo

Comments (7)

msailes avatar msailes commented on September 15, 2024

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.

msailes avatar msailes commented on September 15, 2024

Closing awaiting more information.

from aws-lambda-java-libs.

natanfudge avatar natanfudge commented on September 15, 2024

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:
async programming for dummies

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.

msailes avatar msailes commented on September 15, 2024

Each execution environment of a Lambda function only handles one request at once.

from aws-lambda-java-libs.

natanfudge avatar natanfudge commented on September 15, 2024

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.

marksailes avatar marksailes commented on September 15, 2024

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.

natanfudge avatar natanfudge commented on September 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.