A lightweight Fastly Compute@Edge runtime for running wasm applications locally
Fastly allows you to run WASM request within a WASI-based runtime on its edge servers. fasttime implements those
runtime interfaces using wasmtime served on a local HTTP server allowing you to run you Compute@Edge applications ✨ locally
on your laptop ✨.
The fastest way to get started with Compute@Edge is though the Fastly CLI
$ fastly compute buildIf you do not have Fastly CLI, you can also build with the standard cargo tooling. Fastly assumes a Rust toolchain version of 1.46.0
# optionally install the wasm32 toolchain if you have not done so already
$ rustup target add wasm32-wasi --toolchain 1.46.0
# build a release mode .wasm executable
$ cargo +1.46.0 build --release --target wasm32-wasiTo start fasttime, just provide it with the path to your Fastly Compute@Edge .wasm build artifact.
$ fasttime -w target/wasm32-wasi/release/app.wasmThis starts up a localhost HTTP server listening on port 3000 which you can interact with with
an HTTP client like curl
curl -i "http://localhost:3000"A common usecase for Fastly is proxying a set of backend hosts referred to by name. fasttime supports
providing multiple -b | --backend flags with values of the form {backend}:{host}. By default, if you
send a request to a backend that you have not mapped, a bad gateway response will be returned by the server.
$ fasttime -w target/wasm32-wasi/release/app.wasm \
-b backend-two:localhost:3001 \
-b backend-two:you.comA common way to store lookup information in Fastly is to use edge dictionaries. fasttime supports
providing multiple -d | --dictionary flags with values of the form {dictionary}:{key}={value},{key2}={value2}.
$ fasttime -w target/wasm32-wasi/release/app.wasm \
-d dictionary-one:foo=bar \
-d dictionary-two:baz=boomThe Compute@Edge runtime supports the notion of remote logging endpoints. These are addressed by name within your applications.
use fastly::log::Endpoint;
let mut endpoint = Endpoint::from_name("endpoint-name");
writeln!(endpoint, "hello {}", "wasm");fasttime currently support these by logging directly to stdout by default.
Set the RUST_LOG env variable to fastime=debug and run the cli as usual
RUST_LOG=fasttime=debug fasttime -w target/wasm32-wasi/release/app.wasm
- tls support
- support config file based configuration
- hot reloading of wasm file
Doug Tangren (softprops) 2020