Giter Club home page Giter Club logo

host'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.

host's People

Contributors

maxmcd avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

host's Issues

Local usability next steps

  • Enable load_balancer locally. Agent should handle proxying traffic from those port requests to the various containers. Can likely re-use proxysocket.
  • add start and stop commands to start and stop the local cluster. the start command should report errors about dns port availability
  • run to run a file (this might change, how to apply one file or part of a file or many interlinked files?)
  • status command listing running jobs and their status

Add `agent -dev` to cli

Or maybe a more user-friendly command. Maybe just dev. Should spin up all necessary docker containers to develop locally. From there running deploy commands will deploy locally.

Should be able to run a stop command to clean up, subsequent runs of the dev command should ensure containers are up to date.

Create docker network subnets for users

Part of #4

A user's containers need to be able to address each other, they do this on the ip address that is allocated to the container. If we group users on a given machine into their own subnet range we will get network isolation between containers.

  • Which ip ranges should we allocate?
  • How do we manage the lifecycle of a network's ip range? Can we edit a docker network's ip range?

Prevent port conflicts with load balancer

We currently return a fixed ip addr for dns queries for proxied services. If a container is every connected to two different services with the same port we won't be able to distinguish the requests, eg:

container(
    "dashboard",
     image="hashicorpnomad/counter-dashboard:v1"
     ports=[9002],
     connect_to=["counter.counter:9001", "foo.counter:9001"],
)

This is easily solvable because the ip address is synthetic, we can return any value we like.

  • How should we allocate these addresses?
  • What range should they be in?
  • Where do we track this?

Block access to load balancer endpoints

Part of #4
Load balancer endpoints broadcast on a port and ip that is addressable by all containers. Figure out how to block requests for all other containers.

  • IPTables?
  • Can we block everything and just opt services into access as needed?

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.