Comments (4)
@cristim You are right! I was confused with something else to be honest on Lambda. Cool, then this package is exactly what I was looking for;p Thanks
ps. Although I would still make the vars private/local instead of global to keep the stateless feature clear;p
from archive_aws-lambda-go-net.
That's just how Lambda works internally.
Lambda executes the code in a container that is started fresh or resumed for each and every invocation and then paused once it is done, but a single function call is running in the container at a given time.
When the function is called at a high enough rate, the runtime instantiates more such containers, and schedules the runs there in order to handle the extra load. The idle containers get destroyed after a period of inactivity.
See the documentation for more details.
from archive_aws-lambda-go-net.
@lambrospetrou there are two aspects when running in the AWS Lambda environment:
- Executions are isolated: one and only one request is handled at any time.
- Executions should be stateless: goroutines must complete before the code exits.
I admit that these aspects are weird to deal with. Mostly the second one as we have noticed very strange behaviors when goroutines does not complete before exit.
That being said, this project aims to provide a net
listener for AWS Lambda. As such, it should behave like a net interface which respects the two above aspects. So we have a blocking channel to start the processing and a blocking channel to ensure that we won't exit before an answer is returned from the user handler (as Go http
package internally uses goroutines).
For the other part of your question concerning the private/local vars instead of global vars, this is more a matter of design. In usual cases, you would probably never code something like this, but in AWS Lambda it is more acceptable.
To comply with above two aspects, one need to have some kind of "coordinator". In the case of AWS Lambda global state (along with this bunch of global variables) does the job, simply.
PS: At the time being, the project still uses the first version of our Go shim https://github.com/eawsy/aws-lambda-go. But we've recently released a new version which leverages Go 1.8 plugins https://github.com/eawsy/aws-lambda-go-shim. Also, in the next coming days, we will migrate this project to use the new version of the shim. The code should become more simple and clear, and we will try to take into account your remarks. Keep connected ;)
from archive_aws-lambda-go-net.
Great news;p I will go over your new package (....go-shim) although it seems a bit more complicated than the existing one.
I will keep an eye.
from archive_aws-lambda-go-net.
Related Issues (9)
- Why init not main? HOT 3
- Cut a release? HOT 2
- api badge points to confusing place HOT 2
- Crashes with the latest shim version HOT 7
- http.DetectContentType fails to detect posted JPEG upon lambda HOT 1
- 'Process exited before completing request' HOT 7
- redirect not working? HOT 6
- Why listen and serve instead of handling requests in-memory? HOT 1
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 archive_aws-lambda-go-net.