- How to run locally
- How to run tests
- How to update to a newer Deno version
- How to use Dev Container
- Running load tests inside a Dev Container
- Using
tracing-subscriberas a logging backend
To serve all functions in the examples folder on port 9998, you can do this with the example main service provided with this repo
./scripts/run.shTest by calling the hello world function
curl --request POST 'http://localhost:9998/hello-world' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "John Doe"
}'To run with a different entry point, you can pass a different main service like below
./scripts/run.sh start --main-service /path/to/main-service-directory -p 9000using Docker:
docker build -t supabase/edge-runtime .
docker run -it --rm -p 9000:9000 -v ./examples/:/examples supabase/edge-runtime start --main-service /examples/main
./scripts/test.sh [TEST_NAME]This is a fork-based workflow across four repositories, not a version-string edit. In order:
p-hoffmann/rusty_v8— branchsupabase-v<V8_VERSION>from the upstream tag that the target Deno release pins inlibs/deno_v8/Cargo.toml. Carry the cppgc/isolate null guards forward. Publish release assets for x86_64 and aarch64;.devcontainer/install.shand CI consume them.p-hoffmann/deno— branchtrex-v<DENO_VERSION>from the upstream tag and rebase the trex patches.git diff v<PREV>..trex-v<PREV>lists them. Pointlibs/deno_v8at the rusty_v8 branch from step 1. Gate oncargo check --workspaceinside the fork.- This repo — bump every
deno_*pin in[workspace.dependencies]to match the target tag'sCargo.toml, retarget every[patch.crates-io]entry to the new fork branches, bumpdeno/Cargo.toml, and re-sync the vendoreddeno/crate against upstreamcli/. OHDSI/trex— the parent repository, atplugins/runtime/, vendors this repo as a git submodule and builds with--features trex, which this repo's CI never exercises. Coordinate the bump there.
The snapshot extension lists in crates/base/build.rs and
crates/base/src/runtime/mod.rs must stay name- and order-identical;
crates/base/tests/snapshot_extension_parity.rs enforces this.
See docs/superpowers/specs/ for the design record of past upgrades.
This repository uses Dev Container for a unifying local development environment.
-
Dev Container requires VS Code and Docker to be pre-installed to use it.
-
It is recommended to increase the maximum memory allocated to the Dev Container to at least 24GB, otherwise you may run into spurious errors while compiling. This can be configured via the Docker CLI or the Docker Desktop at
Settings -> Resources -> Advanced -> Memory.
-
Install the Dev Containers extension to VS Code.
-
Open the command palette, and select
Dev Containers: Open Folder in Container...
This section assumes that you have completed the Dev Container configuration on your local machine. If you don't have it configured, go back to this section.
Dockerfile in the .devcontainer only pulls in the required packages, so you'll
need to install additional packages for load testing.
edge-runtime repository already has a script located in k6/scripts/setup.sh
that automates the process of installing these packages.
You can run this script from a shell to automatically get your setup ready for load testing.
vscode ➜ /workspaces/edge-runtime $ cd ./k6/scripts/
vscode ➜ /workspaces/edge-runtime/k6/scripts $ ls
setup.sh
# Note that the commands below are prefixed with `sudo`.
vscode ➜ /workspaces/edge-runtime/k6/scripts $ sudo ./setup.shOnce you run the script, you no longer need to run it again unless you delete the dev container or reinitialize the volume.
After running the script, k6 should run normally as shown below.
vscode ➜ /workspaces/edge-runtime/k6/scripts $ k6 --help
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
Usage:
k6 [command]
Available Commands:
archive Create an archive
cloud Run a test on the cloud
completion Generate the autocompletion script for the specified shell
help Help about any command
...Once you've confirmed that k6 is run properly, you can proceed to load testing.
-
Run
./scripts/run.shin your shell to run edge-runtime.vscode ➜ /workspaces/edge-runtime $ pwd /workspaces/edge-runtime vscode ➜ /workspaces/edge-runtime $ cat ./scripts/run.sh #!/usr/bin/env bash GIT_V_TAG=0.1.1 cargo build && EDGE_RUNTIME_PORT=9998 RUST_BACKTRACE=full ./target/debug/trex "$@" start --main-service ./examples/main --event-worker ./examples/event-manager vscode ➜ /workspaces/edge-runtime $ ./scripts/run.sh Compiling base v0.1.0 (/workspaces/edge-runtime/crates/base) Compiling cli v0.1.0 (/workspaces/edge-runtime/crates/cli) Finished dev [unoptimized + debuginfo] target(s) in 1m 59s warning: the following packages contain code that will be rejected by a future version of Rust: cexpr v0.3.6, nom v4.2.3 note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1` event manager running main function started
-
Run k6 in another shell with the scenario script path
vscode ➜ /workspaces/edge-runtime $ k6 run ./k6/dist/specs/simple.js /\ |‾‾| /‾‾/ /‾‾/ /\ / \ | |/ / / / / \/ \ | ( / ‾‾\ / \ | |\ \ | (‾) | / __________ \ |__| \__\ \_____/ .io execution: local script: ./k6/dist/specs/simple.js output: - scenarios: (100.00%) 1 scenario, 12 max VUs, 40s max duration (incl. graceful stop): * simple: 12 looping VUs for 10s (gracefulStop: 30s) running (09.9s), 12/12 VUs, 12514 complete and 0 interrupted iterations simple [====================================>-] 12 VUs 09.9s/10sIf you want to visualize the results in real-time, set the
K6_WEB_DASHBOARD=trueenvironment variable as shown below.vscode ➜ /workspaces/edge-runtime $ K6_WEB_DASHBOARD=true k6 run ./k6/dist/specs/simple.js
This will expose the endpoints that can view the visualized data.
The load testing scripts are located in
k6/specs. You can look atk6/specs/simple.tsto implement your own if you need additional load-testing scenarios.If load testing scripts have changed, you need to recompile them by performing the command below in your shell.
vscode ➜ /workspaces/edge-runtime/k6 $ npm run build > edge-runtime-load-testing@1.0.0 build > vite build The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. vite v5.1.6 building for production... ✓ 2 modules transformed. Entry module "specs/simple.ts" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning. dist/specs/simple.js 0.72 kB │ gzip: 0.46 kB ✓ built in 72ms
For more about k6, see this documentation.
Sometimes the default logging backend may not provide enough information to
debug edge-runtime. In that case, you can replace the logging backend with
tracing-subscriber to get more detailed logs.
The cargo feature for replacing the logging backend is cli/tracing, and you
can simply replace it by adding arguments as shown below.
# scripts/run.sh
-GIT_V_TAG=0.1.1 cargo build && EDGE_RUNTIME_PORT=9998 RUST_BACKTRACE=full ./target/debug/trex "$@" start \
+GIT_V_TAG=0.1.1 cargo build --features cli/tracing && EDGE_RUNTIME_PORT=9998 RUST_BACKTRACE=full ./target/debug/trex "$@" start \
--main-service ./examples/main \
--event-worker ./examples/event-manager