Go WebAssembly Serverless Platform
A lightweight serverless platform in Go for running WebAssembly (WASM) functions via REST APIs, with support for in-memory or Redis-based function registries, concurrent execution, and queuing.
- WASM Function Execution: Upload and invoke WebAssembly functions through RESTful endpoints.
- Function Registry: Store and manage functions using in-memory or Redis-based registries.
- Concurrency & Queues: Execute multiple function invocations concurrently and queue excess requests per function.
- Timeouts & TTL: Control execution timeouts and cached function TTL.
- JSON Output: Functions return JSON-formatted responses.
- Modular Design: Easily extendable, suitable for testing serverless patterns.
- WASM Function Testing: Upload and execute custom WebAssembly modules.
- Serverless Experimentation: Prototype serverless architectures with concurrency, caching, and queues.
- Custom FaaS Platforms: Build and test foundations for Function-as-a-Service systems.
- Go 1.21+
- WASI SDK (https://github.com/WebAssembly/wasi-sdk)
- Redis (optional, if using Redis registry)
Create a .env file in the project root:
SERVER_PORT=8080
REGISTRY_TYPE=memory # memory or redis
REDIS_ADDR=localhost:6379
REDIS_PASSWORD=
REDIS_DB=0
DefaultTTL=0 # TTL for cached functions in seconds (0 = unlimited)
DEFAULT_FUNC_CONCURRENCY=4 # Max concurrent executions per function
MAX_NODE_CONCURRENCY=0 # Max concurrent executions for the node (0 = unlimited)
QUEUE_SIZE_PER_FUNCTION=128 # Max queued requests per function
INVOKE_TIMEOUT_MS=5000 # Timeout per invocation in millisecondsgo run main.goServer will start on http://localhost:8080.
| Method | Path | Description |
|---|---|---|
| POST | /upload | Upload a WASM file |
| POST | /:name/invoke | Invoke a function by name |
| GET | /functions | List uploaded functions |
#include <stdio.h>
__attribute__((export_name("hello")))
void hello() {
printf("{\"message\": \"hello world\"}\n");
fflush(stdout);
}& "C:\path\to\wasi-sdk\bin\clang.exe" `
--target=wasm32-wasi `
--sysroot="C:\path\to\wasi-sdk\share\wasi-sysroot" `
-O2 hello.c -o hello.wasmcurl.exe -X POST http://localhost:8080/upload -F "file=@hello.wasm" -F "name=hello"curl.exe -X POST http://localhost:8080/hello/invoke -H "Content-Type: application/json" -d "{}"Expected output:
{"message":"hello world"}go-wasp/
├── api/ # HTTP API handlers
├── config/ # Configuration management
├── constants/ # Constant values and enums
├── executor/ # WASM function execution and dispatcher
├── internal/ # Internal utilities
├── registry/ # Function registry implementations
├── .env # Environment variables
├── hello.wasm # Sample WASM function (Hello World)
├── main.go # Entry point
└── README.md # Project documentation
MIT License — see the LICENSE file for details.