GithubHelp home page GithubHelp logo

isabella232 / serverless-open-runtime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverless/serverless-open-runtime

0.0 0.0 0.0 1.18 MB

WIP - An extensible, community-driven, open-runtime for serverless compute

Home Page: https://www.serverless.com

Shell 2.26% JavaScript 26.77% Makefile 17.65% Go 43.92% Python 9.39%

serverless-open-runtime's Introduction

The Serverless Open Runtime for AWS Lambda

This uses AWS's Runtime API for Lambda to implement a universal runtime.

When done it will feature (exact list TBD):

Try it out

npm i -g serverless # make sure you have serverless framework verison 1.34.0 or greater
make
sls deploy
cd example
sls deploy
sls invoke -f hello

NodeJS debugging!

The open runtime implementation Node JS supports remote debugging. To use it:

  1. ensure you have a high timeout on your lambda (or else it'll be killed while debugging)
  2. on a publicly accessible server, install socat and run:
    socat -v TCP-LISTEN:9999,reuseaddr,fork TCP-LISTEN:4444,reuseaddr
    
  3. invoke your lambda with the _debugProxy key in the event set to 1.1.1.1:4444 but changing 1.1.1.1 to the IP address of the server you stared socat on:
    sls invoke -f hello -d '{"_debugProxy": "1.1.1.1:4444"}'
    
  4. open the chrome debugger to chrome-devtools://devtools/bundled/inspector.html?ws=1.1.1.1:4444 (again changing 1.1.1.1 to your server's IP)

Middlewares

The current plan for middlewares allows them to be written in any language by invoking the middleware as an executable with the event or response passed in via standard in & out. The first argument specifies the hook that is being invoked.

Middlewares are best stored in layers and must be stored in the middlewares directory (IE: /opt/middlewares/ inside the lambda execution environment)

To specify the handler middlewares your function should use, set the SLSMIDDLEWARES environment variable to a comma delimited list of middlewares by the filename of the middleware executable. Note: it's possible to make a layer imply a middleware by searching for the file of the same name as the layer, but it requires an API call to get the lambda's configuration at runtime startup (slower cold start) and might be more AWS specific than is desireable.

Middleware specifics example

If you set SLSMIDDLEWARES=test when an event, say {"foo": "bar"} is recieved, the equivalent following will be executed:

echo '{"foo": "bar"}' | /opt/middlewares/test before

and the STDOUT of the that execution will be read and replace the original event.

Then, when the user handler returns a response, say: {"body": "hello"} the middleware will similarlly be invoked as the equivalent of:

echo '{"body": "hello"}' | /opt/middlewares/test after

and the STDOUT will replace the original response.

Potential downsides of this middleware architecture

How will can this be leveraged to implement APM style monitoring that usually monkeypatches language constructs.

Language Agnostic

The current Proof of Concept is implemented in NodeJS 10, but the final open runtime will likely be implemented in Go. A language runtime will be specified to the open runtime to support specific languages.

This allows the open runtime to have a single implementation while supporting many languages. A language-runtime will be started when the open-runtime starts and communicate with it via STDIN & STDOUT as it receives events. There is currently an implementation of this for nodejs 10

serverless-open-runtime's People

Contributors

dschep avatar

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.