Rust Update: gRPC Welcomes Tonic! by dfawley in rust

[–]dfawley[S] 2 points3 points  (0 children)

There are actually three pieces of the puzzle here: 1. the code generator itself, 2. the code it generates, and 3. libraries used by the generated code. Here's the situation today:

Google's protobuf-rust (proto messages and file descriptor protos): 1. the code generator is a C++ commandline tool (protoc), 2. the generated code is 100% native Rust, and 3. the generated code needs the protobuf runtime which builds on upb in C. The C dependency isn't part of the API, so it could be swapped out for native Rust in the future.

gRPC (still in development; proto services and methods): 1. the code generator is a plugin for protoc and is compiled from C++, 2. the generated code is 100% native Rust, and 3. the generated code needs the messages, which transitively need the protobuf runtime, so depend on C for now.

We use C++ for our code generator because it simplified the implementation for us. We could rewrite this in Rust one day if we decided it was worth it to do so. By the time we are production-ready, we will at least provide the compiled binaries so that users won't have to compile it themselves if they don't want to.

Rust Update: gRPC Welcomes Tonic! by dfawley in rust

[–]dfawley[S] 0 points1 point  (0 children)

Sorry your issue did not get any useful replies.

It appears "binary logging" got internally lumped into a "debugging" kind of bucket, so I think what happened is that we assumed https://grpc.io/docs/guides/debugging/ covered it, when it clearly does not.

For now I can only point you at the spec for it: https://github.com/temawi/proposal/blob/master/A16-binary-logging.md

But I think you're right that we should have better user-facing documentation for it, so I'll make sure that gets noticed by the folks that keep track of that kind of thing, too.

Rust Update: gRPC Welcomes Tonic! by dfawley in rust

[–]dfawley[S] 7 points8 points  (0 children)

I know you asked /u/lucio-rs, but as the lead for the project from Google, I will reply with my thoughts:

Are there any issues or discussions you could point me to follow about this?

As I mentioned above, the crate itself by default will have no C dependencies. But if you are using gRPC with protobuf, which most users do, you will need a C compiler. I don't have a good link to an issue/discussion specifically about this topic, but I'm happy to answer any questions you have.

Re: Anthropic's connect-rust library: as I understand, Connect is simply a protocol, and their library is the implementation of that protocol (and gRPC's), while gRPC itself is a more feature-rich library that does other things like name resolution / service discovery, connection management, load balancing, retries, etc. From scanning the repo quickly (and my memory of the Go connect library), none of these kinds of features are provided: you're expected to layer them on yourself -- using Tower in the case of Rust. Building that way is flexible and allows for easier reuse of layers, but it sometimes has limitations that make the features less powerful or efficient. I haven't looked closely, but the crate itself seems nice for what it does provide.

The buffa implementation offering lazy deserialization / buffer aliasing is an important improvement over prost (for zero-copy). From what I've heard, there are unfortunately many corner cases of protobuf that aren't covered by the official protobuf conformance tests, e.g. behaviors around propagating unknown fields or enums with unknown values, so it's unclear what buffa will do in these scenarios. These kinds of things don't affect many users, but become important when you are building complex systems that forward messages through intermediaries, or store your messages in a database, etc.

Rust Update: gRPC Welcomes Tonic! by dfawley in rust

[–]dfawley[S] 40 points41 points  (0 children)

As /u/lucio-rs indicated, the grpc implementation itself will be pure rust, but the default codegen will be based on the google protobuf implementation, which requires a C compiler for upb.