Skip to content

gRPC example + convenience module#126

Open
fibonacci1729 wants to merge 2 commits intomainfrom
grpc-example
Open

gRPC example + convenience module#126
fibonacci1729 wants to merge 2 commits intomainfrom
grpc-example

Conversation

@fibonacci1729
Copy link
Copy Markdown
Contributor

@fibonacci1729 fibonacci1729 commented Apr 1, 2026

Validated that because tonic's generated server types implement tower::Service<http::Request>, Spin's IncomingBody can be passed through directly — no body-type conversion or custom runtime needed.

Add gRPC support with tonic integration

Adds a grpc module to the Spin Rust SDK and a complete example demonstrating how to serve gRPC endpoints from a Spin component using tonic.

SDK changes

New grpc module grpc.rs behind the grpc feature flag — provides a grpc::serve() helper that forwards Spin's incoming HTTP request to any tower::Service, enabling tonic-generated servers to work out of the box.
New grpc feature in Cargo.toml pulling in tower-service as a dependency.

Example

examples/grpc — A Greeter service with both unary and server-streaming RPCs.
Uses tonic with only codegen + prost (no hyper/tokio transport) so it compiles to wasm32-wasip2.
Includes a proto definition, build.rs for codegen, spin.toml, and a README with grpcurl test commands.

@fibonacci1729 fibonacci1729 changed the title WIP: grpc example gRPC example + convenience module Apr 1, 2026
Signed-off-by: Brian Hardock <brian.hardock@fermyon.com>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be a sub-module of http rather than top level?

@fibonacci1729 fibonacci1729 marked this pull request as ready for review April 1, 2026 20:00
Signed-off-by: Brian Hardock <brian.hardock@fermyon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants