Giter VIP home page Giter VIP logo

minlambda's Introduction

minlambda

A minimalist AWS Lambda runtime for Rust.

fn main() -> ! {
    minlambda::run_ok(|_: serde::de::IgnoredAny| "Hello, world!")
}

What it does

minlambda implements the AWS Lambda runtime interface, deserializing events and serializing responses with Serde JSON.

To communicate with the runtime API over HTTP, minlambda uses a purpose-built HTTP client.

What it doesn't

minlambda doesn't parse response headers in the invocation event (other than the request ID). This includes the function deadline, function ARN, AWS X-Ray tracing header, or additional AWS Mobile SDK data. The crate author has never needed these and, well, this is a minimal runtime.

minlambda doesn't run your handler in an async runtime. If you're using async code, you can create a runtime outside of lambda::run and call its blocking function (e.g. Tokio's Runtime::block_on). An example for Tokio is available.

When not to use this

Probably most of the time.

If you're using Lambda to interact with other AWS services, which is very likely, you are probably using an SDK (such as Rusoto) that probably relies on hyper and Tokio, and you're not really reducing your total dependency closure compared to the AWS Labs runtime.

The HTTP client was built to work with Lambda's runtime API, and not to be a generic RFC-compliant HTTP client; if Lambda's underlying interface subtly changes, this runtime could break unexpectedly. (This probably won't happen: we believe that the subset of the HTTP spec we implement is by the book.)

When to use this

You like simple things, or your code already has minimal dependencies.

Examples

Some lovely examples are available in our repository.

Building Lambda functions

Building binaries that actually work in the Lambda execution environment is a bit of an art, as it contains stable (old) versions of glibc and the like. Your compiler is probably targeting a system with newer shared libraries and symbol versions than what the execution environment has available, resulting in cryptic dynamic linker errors at runtime.

If you find the musl libc toolchain reasonable to work with, building a fully static binary is probably the way to go. If you find containers reasonable to work with, using softprops/lambda-rust is probably the way to go.

Disclaimer

The author of this crate works at AWS, but this is not an official AWS project, nor does it necessarily represent opinions of or recommended best-practices on AWS.

minlambda's People

Contributors

iliana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.