iTranslated by AI
Lessons Learned from Connect's gRPC Interoperability Testing
This article is for the 4th day of the Go Advent Calendar 2022.
In June 2022, Connect, a protocol that extends gRPC, and its Go implementation were announced, becoming a hot topic among developers using Go and gRPC.
The Go implementation of Connect, connect-go, is interoperable with grpc-go, the Go implementation of gRPC. This means that if you currently have an application using grpc-go for clients or servers, you can replace it with connect-go. Of course, this requires some code modifications beyond just swapping libraries, but it allows for independent migration of clients and servers, such as keeping the server running on grpc-go while migrating the client to connect-go.
Regarding grpc-web used on the client side, connect-web is also interoperable. While it is common for gRPC-Web to use grpc-go on the server side and Envoy as a reverse proxy in front, using connect-go on the server side offers the flexibility to either continue using Envoy or remove it entirely.
In this way, connect-go and connect-web are implemented with interoperability with existing gRPC implementations in mind. The repository that conducts these interoperability tests is connect-crosstest. In this repository, while utilizing the official gRPC interoperability test cases, tests are performed across different implementations, such as between grpc-go and connect-go. These tests can be executed locally using Docker Compose.
Since the tests are not performed in a format like *_test.go, it might be difficult to grasp what is happening at first glance, but by looking at dockercomposetestgo and dockercomposetestweb in the Makefile, you can get a general sense of the test patterns being conducted.
When switching from grpc-go to connect-go (or grpc-web to connect-web) in production, even though interoperability is maintained, you will likely want to verify whether each endpoint works correctly. In connect-crosstest, I felt that the way they utilize the decoded results on the client side rather than performing verification on the server side is a point that could be a useful reference when writing verification code[1]. For Go clients, the proto#Equal function is used for verification, which also seems useful.
Besides the official implementation, another well-known gRPC-Web implementation is improbable-eng/grpc-web. It might be an interesting attempt to fork connect-crosstest and include this in the interoperability tests as well.
I believe that in 2023, we will see an increasing number of cases where Connect is adopted in production. The ecosystem around gRPC still has a lot of room for growth, and I look forward to its future evolution.
-
Example of server-side verification: https://shopify.engineering/how-shopify-reduced-storefront-response-times-rewrite ↩︎
Discussion