Giter VIP home page Giter VIP logo

lucet's Introduction

embly

A serverless web application framework for collaboration and scale.

For more background and details about what embly is read here or here

Hello World

Create a new folder and add the following files and directory structure:

├── embly.hcl
└── hello
    ├── Cargo.toml
    └── src
        └── main.rs

Now add the following file contents:

embly.hcl:

function "hello" {
  runtime = "rust"
  path    = "./hello"
}

gateway {
  type = "http"
  port = 8765
  route "/" {
    function = "${function.hello}"
  }
}

hello/Cargo.toml:

[package]
name = "hello"
version = "0.0.1"
edition = "2018"

[dependencies]
embly = "0.0.5"

hello/src/main.rs:

extern crate embly;
use embly::{
  http::{run_catch_error, Body, Request, ResponseWriter},
  prelude::*,
  Error,
};

async fn execute(_req: Request<Body>, mut w: ResponseWriter) -> Result<(), Error> {
  w.write_all(b"Hello World")?; // writing our hello response bytes
  Ok(()) // if an error is returned the server will respond with an HTTP error
}

// this function is run first
fn main() {
  run_catch_error(execute); // this is the embly::http::run function that is specific to http responses
}

You can now run your project for local development with embly dev, although the fastest way to get started is with docker:

docker run -v /var/run/docker.sock:/var/run/docker.sock  -v $(pwd):/app -p 8765:8765 -it embly/embly embly dev

More on how to run embly in the installation section.

The embly Command

$ embly
Usage: embly [--version] [--help] <command> [<args>]

Available commands are:
    build     Build an embly project
    bundle    Create a bundled project file
    db        Run various database maintenace tasks. 
    dev       Develop a local embly project
    run       Run a local embly project

Installation

embly uses docker to download and run build images. It's recommended that you run embly from within a docker container and give it access to the docker socket. If you are in the root of an embly project you can start the dev server like so:

docker run -v /var/run/docker.sock:/var/run/docker.sock  -v $(pwd):/app -p 8765:8765 -it embly/embly embly dev

If you would like to run embly locally you'll need to have cargo and go installed. The following sequence of commands should work:

go get github.com/embly/embly/cmd/embly
cargo install embly-wrapper
cargo install lucetc

Links


embly used to be wasabi, which was more focused on providing full operating system functionality within a webassembly runtime. That code is available here.

lucet's People

Contributors

0xflotus avatar 11takanori avatar acfoltzer avatar awortman-fastly avatar daisukefuji avatar data-pup avatar ekilmer avatar freebroccolo avatar ggreif avatar hnakamur avatar htfy96 avatar jedisct1 avatar jfoote avatar pchickey avatar shravanrn avatar singpolyma-shopify avatar tschneidereit avatar tyler avatar

Watchers

 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.