Giter Site home page Giter Site logo

veryjos / lando Goto Github PK

View Code? Open in Web Editor NEW

This project forked from softprops/lando

0.0 2.0 0.0 741 KB

a smooth-talking smuggler of rust functions into aws lambda

Home Page: https://crates.io/crates/lando

License: MIT License

Rust 97.44% Makefile 0.84% Shell 1.73%

lando's Introduction

lando Build Status Coverage Status crates.io docs.rs Master API docs

aws lambda api gateway interfaces for Rustlang applications

#[macro_use] extern crate cpython;
#[macro_use] extern crate lando;

gateway!(|_, _| {
  Ok(lando::Response::new("Hello, what have we here?"))
});

๐Ÿค” about

๐Ÿšง ๐Ÿ‘ท๐Ÿฟโ€โ™€๏ธ ๐Ÿ‘ท๐Ÿฝ ๐Ÿ‘ทโ€โ™€๏ธ ๐Ÿ‘ท ๐Ÿšง this project is currently active under construction. expect changes.

Lando is a crate for serverless rustlang HTTP applications.

The rustlang ecosystem has a number of really great HTTP server crates. If you're interested in writing HTTP applications, you may want to evaluate them as well. A common theme they share is in providing interfaces for authoring applications, in addition to interfaces for configuring servers that listen on ports that expose your application over network connections. A server which is then your reponsiblity to figure out how to host, scale, monitor and manage operations and uptime for.

Lando is different. Lando's focus is solely on writing applications. AWS will manage servers for you, freeing you from the business and toil of the undifferentiated heavy lifting that comes along with managing servers yourself.

Lando is designed to work with the interfaces of strong existing ecosystems, both within Rust as well as the strong serverless ecosystems that extend beyond Rust ( make some friends! ).

Lando's embraces the Rust community standard http crate as it's interface for api gateway. The http crate was extracted from the work of a number of successful projects and was designed as a framework-agnostistic and extensible http library. Lando extends the existing work of the crowbar crate which provides needed lower level machinery for easily embeding a Rust application with one of lamdba's lowest overhead runtimes, python 3.6. Lando specifically targets API Gateway triggered lambdas. Checkout crowbar for other types of lambda triggers.

A large and mature ecosystem of tooling for AWS lambda already exists and works well, including workflow tools like the serverless toolkit. Because these tools are likely to already exist within organizations, the barrier of introducing Rustlang into their arsenel will be much lower. Lando does not intend to replace these tools but instead to work well with them ๐Ÿ‘ซ๐Ÿพ.

๐Ÿ’ก You may be asking yourself, what makes Rust a good choice for Lambda? The AWS cost model for lambda is largely based on two factors: memory size and speed. The CPU provided to applications is proportional to memory size requested. Lambda has a pay per usage cost model billing favoring applications that are both fast and have low memory overheads. As a systems language, Rust is designed specifically for these kinds of needs. Rust has a very tiny runtime, manages memory very effciently, and is extremely fast. . As a highly embeddable language, its interop story for runtimes like python's is ๐Ÿ’–. Be mindful that lando assumes you're exposing these applications through AWS API gateway which has its own generous pricing model.

๐Ÿ“ฆ install

Add the following to your cargo project's Cargo.toml file.

[lib]
name = "lambda"
crate-type = ["cdylib"]

[dependencies]
lando = "0.1"
cpython = "0.1"

๐Ÿ’ก You may be new to the cdylib and crate-type lib attributes. This informs rustc to link and produce a shared object ( *.so ) file allowing your rustlang application to be embedded within the AWS python 3.6 lambda runtime

๐Ÿ‘ฉโ€๐Ÿญ create

Lando exports a macro named gateway! which in turn, injects a Rust function or closure to a cpython initializer making it ready for use within an aws lambda.

#[macro_use] extern crate cpython;
#[macro_use] extern crate lando;

gateway!(|request, _context| {
  println!("{:?}", request);
  Ok(lando::Response::new(()))
});

This closure accepts an http::Request with a lando::Body. This body can be dereferenced as a slice of bytes.

For more more in-depth details see this project's crate documentation.

๐Ÿš€ deploy

In order to deploy your app you will need to build it within a runtime compatible with the lambda python 3.6 env.

docker

A docker image is provided for convenience

It's focus is on applications targetting stable versions of Rust.

$ docker run --rm \
        -v ${PWD}:/code \
        -v ${HOME}/.cargo/registry:/root/.cargo/registry \
        -v ${HOME}/.cargo/git:/root/.cargo/git \
        -e CARGO_FLAGS="--features lando/python3-sys" \
        softprops/lambda-rust

This will result in a deployable .so build artifact under a target/lambda directory

This file can then be zipped up for AWS lambda deployment.

serverless framework

A serverless framework plugin exists to facilitate rapid development/deployment cycles.

The fastest way to get started with lando is by using this serverless project template

$ serverless install \
  --url https://github.com/softprops/serverless-lando \
  --name my-new-service

Doug Tangren (softprops) 2018

lando's People

Contributors

softprops avatar srijs avatar

Watchers

James Cloos avatar veryjos 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.