Minimal example making webpack and wasm/Emscripten work together.
Build instructions:
- Clone this gist
npm install
npm start
- Open
http://localhost:8080
- Look at console
Minimal example making webpack and wasm/Emscripten work together.
Build instructions:
npm install
npm start
http://localhost:8080
Doxbee sequential | |
benchmarking ./doxbee-sequential/async-bluebird.js | |
{"time":428,"mem":60.38671875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-native.js | |
{"time":591,"mem":98.82421875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-util.promisify.js | |
{"time":479,"mem":69.7734375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/callbacks-baseline.js | |
{"time":149,"mem":29.99609375,"errors":0,"lastErr":null} |
Koa middleware cascade in a more traditional way as you may be used to with similar tools - this was previously difficult to make user friendly with node's use of callbacks. However with async functions we can achieve "true" middleware. Contrasting Connect's implementation which simply passes control through series of functions until one returns, Koa invoke "downstream", then control flows back "upstream".
The following example responds with "Hello World", however first the request flows through the x-response-time and logging middleware to mark when the request started, then continue to yield control through the response middleware. When a middleware invokes next() the function suspends and passes control to the next middleware defined. After there are no more middleware to execute downstream, the stack will unwind and each middleware is resumed to perform its upstream behaviour.
const Koa = require('koa');
const app = new Koa();
{ | |
"service_id":"%{req.service_id}V", | |
"service_version":"%{fastly_info.version}V", | |
"time_start":%{begin:msec}t, | |
"time_end":%{end:msec}t, | |
"time_elapsed":%{time.elapsed.usec}V, | |
"client_ip":"%{req.http.Fastly-Client-IP}V", | |
"request":"%{req.request}V", | |
"protocol":"%{req.proto}V", | |
"host":"%{req.http.Fastly-Orig-Host}V", |
#!/bin/bash | |
LATESTNGINX="1.11.10" | |
BUILDROOT="/tmp/boring-nginx" | |
# Pre-req | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
# Install deps |
module.exports = function atob(a) { | |
return new Buffer(a, 'base64').toString('binary'); | |
}; |
# Unique request ID header | |
sub vcl_recv { | |
set req.http.X-Request-ID = digest.hash_sha256(now randomstr(64) req.http.host req.url req.http.Fastly-Client-IP server.identity); | |
#FASTLY recv | |
} |