multi: migrate from gRPC to Connect RPC#348
Open
torkelrogstad wants to merge 3 commits into
Open
Conversation
98b439b to
68ba50a
Compare
Connect is a simple RPC alternative to gRPC that is fully compatible with existing gRPC clients. We also gain the ability for plain `curl` to be used as a client.
Implemented via a new crate that is not yet merged into upstream: anthropics/connect-rust#128
68ba50a to
c234066
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connect is a replacement for gRPC. It is effectively
a simplified version of gRPC. gRPC clients can still communicate with Connect
servers, without having to make any changes at all. One of the big benefits of
Connect is that it is possible to use a completely plain HTTP client as well
(for example just
curl!).All of these work fine:
$ curl -X POST -H 'Content-Type: application/json' http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalance $ grpcurl -plaintext localhost:50051/cusf.mainchain.v1.WalletService/GetBalance $ buf curl http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalanceWhy bother?
The biggest benefit is that clients no longer need to bother
with gRPC at all. gRPC is notoriously hard and complex to deal with.
Generated code, hairy libraries, TLS, lots of strange concepts. People get
frustrated, and give up! With this, we could consider dropping our
home-rolled JSON-RPC server implementation of the validator and wallet
services.
Another change we make is to remove the
cusf_sidechain_protoGit submodule infavor of remote code generation through the Buf Schema Registry. Code generation
plugins are configured in
buf.gen.yaml, and the generated code is checked intoGit. This blows up the diff via lots and lots of generated code (not a big deal,
IMO). The upside is that we can remove a few build dependencies, and that we
avoid the Git submodule in favor of what (I believe) is a simpler way of
upgrading the proto files. Note that we could still do build-time code
generation while using Connect, if we wanted to. Personal preference of mine is
on checked-in generated code: it is very nice to be able to actually read and
examine whatever code we're interacting with, instead of having to dig into the
targetfolder if something is not working as expected.One downside here is that the Connect library does not (yet) support the
reflection API. This is something I assume they'll be adding shortly. The
library is very rapidly iterated on, judging by GitHub activity.
This supersedes #333, as we no longer have to deal with local proto files at all.
TODO:
look into how we can fix the missing health checksimplemented via Add newconnectrpc-healthcrate anthropics/connect-rust#128serve_grpc_portandserve_grpc_addrparameters?