embly

A serverless web application framework for collaboration and scale.

Mission

Embly was born out of the frustration that it's very easy to deploy static web applications across massive CDN's, but it's much more difficult to deploy dynamic programs.

Embly applications are made up of small sandboxed webassembly programs that communicate with each other. Small pieces of code can be recompiled and hot-reloaded, easing development and deploy. Project and applications can be imported and re-used in part or in whole, allowing easy sharing and composition. And resource constraints can be applied to each sandboxed program allowing multiple users to safely share the same cluster.

Building Blocks

Build

No more fiddling with cutting edge webassembly builds. Embly provides the build system for the languages it supports. Your builds will work because they work for the community. Their build and dev improvements will make it to your workflow.

Develop

Embly is a self-contained system, so there's nothing stopping the development experience from being top notch. The vision is that you'll be able to develop Embly apps in a web brower, native app, or on your personal computer, with full support for linting, testing, code generation, and various tools in each environment.

Deploy

Embly clusters can trivially support multi-tenancy. You can set up a shared cluster with your friends or deploy your application with a third-party and pay for just the resources your application uses when responding to requests.

Collaborate

Embly applictions are design to be shared. Their modularity means you can try out small peices of a shared application and deploy things to test out in seconds.

Further Reading:

You can learn more about Embly by reading What is Embly or by checking out the source and examples on github: github.com/embly/embly

The site you're on now is also an Embly application. You can check out the example authentication application. It uses the Embly key-value store to store user data and processes all login and registration logic with webassembly functions.

Minimal 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}"
  }
}

Cargo.toml:
[package]
name = "hello"
version = "0.0.1"
edition = "2018"

[dependencies]
embly = "0.0.5"

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
}

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

Congrats! You've run your first Embly project.

(careful! For the moment, Embly needs access to the docker socket to download and run build containers. This involves a lot of trust as it gives full control to the docker daemon.)

Posts:
Links: