π Getting Started
Use the Capsule HTTP server
First, download the last version of the Capsule HTTP server for the appropriate OS & ARCH (and release version):
Write a WASM Capsule module
Build the WASM module:
Serve a WASM Capsule module
To run a WASM Capsule module you need to set 2 flags:
--wasm: the path to the WASM module--params: the parameter to pass to the WASM module
You can query the service like this:
You can remotely download the WASM module with the --url flag:
π if you need to set an authentication header you can use these flags:
--authHeaderNameand--authHeaderValue:
Monitoring the service
Capsule HTTP server exposes a REST API (/metrics endpoint) that can be used to monitor the service. You have to write the logic to generate the metrics and expose them to Prometheus.
An HTTP request to the /metrics endpoint will trigger the call of the exposed OnMetrics function of the WASM module. You need to implement the OnMetrics function in your WASM module:
- Don't forget to expose the function:
//export OnMetrics- You can find a complete sample here: hello-world sample
Health Check
Capsule HTTP server exposes a REST API (/health endpoint) that can be used to teturn a health status. You have to write the logic to generate the status.
An HTTP request to the /health endpoint will trigger the call of the exposed OnHealthCheck function of the WASM module. You need to implement the OnHealthCheck function in your WASM module:
- Don't forget to expose the function:
//export OnHealthCheck- You can find a complete sample here: hello-world sample
OnStart and OnStop functions
You can add a OnStart and OnStop function to the WASM module. These functions will be called when the service starts and stops.
- Don't forget to expose the functions
- You can find a complete sample here: hello-world sample
Develop a WASM Capsule module
Have a look to these samples: