wasi-grpc
Enables gRPC clients to work inside Spin components using wasi-hyperium and the spin-rust-sdk.
Spin is a fast, secure WebAssembly framework for serverless apps. This project extends Spin's capabilities by enabling components to make outbound gRPC requests, bridging the gap between Wasm sandboxing and modern microservice communication.
๐ Features
- ๐งฉ gRPC over HTTP/2 support inside Spin apps
- ๐ Compatible with the Spin sandbox security model
- ๐ฆ Built with
wasi-hyperiumandtonic - ๐ Works with most standard gRPC services
- ๐งช Great for calling internal microservices or public gRPC APIs from Spin
๐ ๏ธ Usage
1. Add required dependencies to your Cargo.toml
[]
= "1"
= "0.3.28"
= "0.13.5"
= "0.1.0"
= "4.0.0"
= { = "0.13.1", = ["codegen", "prost", "router"], = false}
2. Generate gRPC client code with tonic-build
In build.rs:
And in Cargo.toml:
[]
= { = "0.13.1", = ["prost"] }
3. Call your gRPC service from a Spin component
let endpoint = new;
let mut client = new;
let response = client.get_feature.await?;
๐ Spin Notes
This project assumes execution in a Spin-compliant runtime that allows outbound networking via Spin's capability-based model. Ensure your spin.toml includes the appropriate allowed_outbound_hosts granting outbound access to your gRPC service's endpoint.