Below you will find pages that utilize the taxonomy term “FauxRPC”
Using FauxRPC to debug transcoding HTTP/JSON to gRPC
A Stack overflow question involving transcoding HTTP/JSON to gRPC, piqued my interest. I had a hunch on the solution but was initially dissuaded from attempting a repro because of the complexity:
- recreate proto
- implement stubs
- deploy gRPC-Gateway
I then realized that FauxRPC would probably address much of the complexity and it did.
I created foo.proto:
syntax = "proto3";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
// Was not defined in the question.
service Foo {
rpc FetchResource(GetResourceRequest) returns (ResourceResponse) {
option (google.api.http) = {get: "/v1/resource/{resource_id}/group"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Get Resource from group"
description: "Retrieve resource info"
};
}
};
// Should be named FetchResourceRequest to match the RPC method name.
message GetResourceRequest {
string resource_id = 1 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Resource UUID v4."
example: "\"81042622-4f02-4e85-a896-172edd5381b6\""
}
];
ResourceFilter resource_filter = 2 [
(google.api.field_behavior) = OPTIONAL,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "\"RESOURCE_FILTER_FIRST\""
}
];
}
// Empty response for demonstration purposes.
// Was not defined in the question.
// Should be named FetchResourceResponse to match the RPC method name.
message ResourceResponse {}
enum ResourceFilter {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = {
title: "Resource Filter"
example: "\"RESOURCE_FILTER_FIRST\""
};
RESOURCE_FILTER_UNSPECIFIED = 0;
RESOURCE_FILTER_FIRST = 1;
}
The proto depends on googleapis (Google’s repo containing definitions for Google’s services) and grpc-gateway (containing protoc plugins and protobuf sources).
Configuring Envoy to proxy Google Cloud Run v2
I’m building an emulator for Cloud Run. As I considered the solution, I assumed (more later) that I could implement Google’s gRPC interface for Cloud Run and use Envoy to proxy HTTP/REST requests to the gRPC service using Envoy’s gRPC-JSON transcoder.
Google calls this process Transcoding HTTP/JSON to gRPC which I think it a better description.
Google’s Cloud Run v2 (v1 is no longer published to the googleapis repo) service.proto includes the following Services definition for CreateService:
gRPC-Web w/ FauxRPC and Rust
After recently discovering FauxRPC, I was sufficiently impressed that I decided to use it to test Ackal’s gRPC services using rust.
FauxRPC provides multi-protocol support and so, after successfully implementing the faux gRPC client tests, I was compelled to try gRPC-Web too. For no immediate benefit other than, it’s there, it’s free and it’s interesting. As an aside, the faux REST client tests worked without issue using Reqwest.
Unfortunately, my optimism hit a wall with gRPC-Web and what follows is a summary of my unresolved issue.
FauxRPC using gRPCurl, Golang and rust
Read FauxRPC + Testcontainers on Hacker News and was intrigued. I spent a little more time “evaluating” this than I’d planned because I’m forcing myself to use rust as much as possible and my ignorance (see below) caused me some challenges.
The technology is interesting and works well. The experience helped me explore Testcontainers too which I’d heard about but not explored until this week.
For my future self:
| What | What? |
|---|---|
| FauxRPC | A general-purpose tool (built using Buf’s Connect) that includes registry and stub (gRPC) services that can be (programmatically) configured (using a Protobuf descriptor) and stubs (example method responses) to help test gRPC implementations. |
| Testcontainers | Write code (e.g. rust) to create and interact (test)services (running in [Docker] containers). |
| Connect | (More than a) gRPC implementation used by FauxRPC |
| gRPCurl | A command-line gRPC tool. |
I started following along with FauxRPC’s Testcontainers example but, being unfamiliar with Connect, I wasn’t familiar with its Eliza service. The service is available on demo.connectrpc.com:443 and is described using eliza.proto as part of examples-go. Had I realized this sooner, I would have used this example rather than the Health Checking protocol.