Kevin Hoffman
I turn napkin drawings into software
Kevin Hoffman
DEVELOPER SMASH!
DEVELOPER SMASH!
... even using Docker, Kubernetes, etc...
WebAssembly JIT or Interpret Engine
waPC (WebAssembly Procedure Calls)
wascap (capabilities-based security)
wascc-host
Generic waSCC Host Binary
HTTP Server
RDB Client
Cache Client
HTTP Client
Business Logic
Logging
Analytics
Actor
HTTP Server
RDB Client
Cache Client
HTTP Client
extern crate wascc_actor as actor;
#[macro_use]
extern crate serde_json;
use actor::prelude::*;
actor_handlers! {
codec::http::OP_HANDLE_REQUEST => increment_counter,
codec::core::OP_HEALTH_REQUEST => health
}
fn increment_counter(msg: codec::http::Request) -> HandlerResult<codec::http::Response> {
let key = msg.path.replace('/', ":");
let value = keyvalue::default().atomic_add(&key, 1)?;
let result = json!({"counter": value });
Ok(codec::http::Response::json(result, 200, "OK"))
}
fn health(_h: codec::core::HealthRequest) -> HandlerResult<()> {
Ok(())
}
fn handle_call(&self, actor: &str, op: &str, msg: &[u8]) -> Result<Vec<u8>, Box<dyn Error>> {
trace!("Received host call from {}, operation - {}", actor, op);
match op {
OP_BIND_ACTOR if actor == SYSTEM_ACTOR => self.configure(deserialize(msg)?),
OP_REMOVE_ACTOR if actor == SYSTEM_ACTOR => self.remove_actor(deserialize(msg)?),
OP_GET_CAPABILITY_DESCRIPTOR if actor == SYSTEM_ACTOR => self.get_descriptor(),
keyvalue::OP_ADD => self.add(actor, deserialize(msg)?),
keyvalue::OP_DEL => self.del(actor, deserialize(msg)?),
keyvalue::OP_GET => self.get(actor, deserialize(msg)?),
keyvalue::OP_CLEAR => self.list_clear(actor, deserialize(msg)?),
keyvalue::OP_RANGE => self.list_range(actor, deserialize(msg)?),
keyvalue::OP_PUSH => self.list_push(actor, deserialize(msg)?),
keyvalue::OP_SET => self.set(actor, deserialize(msg)?),
keyvalue::OP_LIST_DEL => self.list_del_item(actor, deserialize(msg)?),
keyvalue::OP_SET_ADD => self.set_add(actor, deserialize(msg)?),
keyvalue::OP_SET_REMOVE => self.set_remove(actor, deserialize(msg)?),
keyvalue::OP_SET_UNION => self.set_union(actor, deserialize(msg)?),
keyvalue::OP_SET_INTERSECT => self.set_intersect(actor, deserialize(msg)?),
keyvalue::OP_SET_QUERY => self.set_query(actor, deserialize(msg)?),
keyvalue::OP_KEY_EXISTS => self.exists(actor, deserialize(msg)?),
_ => Err("bad dispatch".into()),
}
}
Docs & Guides
Social
Twitter:
@wascc_runtime, @KevinHoffman
By Kevin Hoffman
An introduction to waSCC, a WebAssembly host runtime that provides secure dispatch between actors compiled to WebAssembly and pluggable capability providers