Hi @benjreinhart
The Fastly Compute@Edge platform enables users to manage routing and behaviours at the edge, and is more akin to a ‘service’ than it is a ‘function’.
You can manage Compute services using either the Fastly CLI or the Fastly Terraform Provider.
But in your case I would imagine your application would want to interact with the Fastly platform via its API:
Your application can either use one of the different language clients available to interact with the Fastly API, or you can write the relevant HTTP calls yourself.
From my understanding of your use case, the code that your users provide to your application would need to be packaged up and deployed to a Compute@Edge service (one service per user application).
This means you would need to use the following API endpoints:
- Create a service (type: wasm)
- Upload a package
As for the second endpoint, the easiest way to produce a package is to use the Fastly CLI but that might not be a feasible option for you depending on how your application is built and what access it has at runtime to a shell environment with the Fastly CLI installed.
Essentially what the CLI is doing is using a compiler (e.g. for a Go program it uses tinygo, for a Rust program it uses the wasm32-wasi
target, etc) to compile the code into a main.wasm
binary and then it wraps the binary + the fastly.toml
manifest into a package.tar.gz
archive and uploads that archive file to the package API endpoint and then ‘activates’ the Compute service.
The structure of the package should look something like this:
$ tar -ztvf testing-fastly-cli.tar.gz
drwx------ 0 integralist staff 0 16 Jun 15:53 testing-fastly-cli/
drwx------ 0 integralist staff 0 16 Jun 15:53 testing-fastly-cli/bin/
-rw-r--r-- 0 integralist staff 13005581 16 Jun 15:53 testing-fastly-cli/bin/main.wasm
-rw-r--r-- 0 integralist staff 663 16 Jun 15:53 testing-fastly-cli/fastly.toml
Any changes to the user’s application code should cause the currently active service version to be cloned and then the code to be recompiled/archived and uploaded, and the newly cloned service version to be activated.
NOTE: Your users’ code would need to use either one of the official language SDKs or a custom/unofficial SDK to interact with the Compute@Edge platform.
Hope this information helps.
Any other questions, then just let us know.
Thanks.