tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Tonic Relection needs a readme/howto

Open 0xAlcibiades opened this issue 2 years ago • 8 comments

Feature Request

Crates

tonic_reflection

Motivation

There are no usage examples and I had to reverse engineer the crate to use it.

Proposal

There should be a readme and/or crate documentation illustrating how to use tonic_reflection

Alternatives

Scour the web/roll my own, which made it hard to use the crate.

0xAlcibiades avatar Sep 16 '23 22:09 0xAlcibiades

+1 on this. Reflection is a little more spread-out than other examples. It's the build.rs, tonic-reflection in Cargo.toml, and finally the example file.

There are many more undocumented examples though, not just this one.

jaredmcqueen avatar Sep 27 '23 02:09 jaredmcqueen

+1 on this. Reflection is a little more spread-out than other examples. It's the build.rs, tonic-reflection in Cargo.toml, and finally the example file.

There are many more undocumented examples though, not just this one.

I'd be down to write up an example if the maintainers would be open to a PR.

0xAlcibiades avatar Sep 27 '23 03:09 0xAlcibiades

+1 on this. Reflection is a little more spread-out than other examples. It's the build.rs, tonic-reflection in Cargo.toml, and finally the example file. There are many more undocumented examples though, not just this one.

I'd be down to write up an example if the maintainers would be open to a PR.

@jaredmcqueen is that a yes?

0xAlcibiades avatar Oct 10 '23 00:10 0xAlcibiades

I'll help out. I've written a few services with tonic now and know my way around reflection. I can't merge PRs though

jaredmcqueen avatar Oct 10 '23 23:10 jaredmcqueen

👀

vastus avatar Oct 14 '23 08:10 vastus

Also agree with this, the example is incomplete.

I cannot figure out how to implement tonic::include_file_descriptor_set!("test")

It just complains that there's no file, but the 'bin' isn't generated for the directory it's looking in, so I'm completely stuck.

build/protobrain-grpc-b9250147e4fbee18/out/test.bin

Screenshot 2023-12-30 at 17 07 26

The error is super cryptic

error: couldn't read /Users/oliverdixon/Projects/protobrain/protobrain-grpc/target/debug/build/protobrain-grpc-ce623c313148455c/out/test.bin: No such file or directory (os error 2)
 --> src/main.rs:5:51
  |
5 |     pub(crate) const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("test");
  |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `include_bytes` which comes from the expansion of the macro `tonic::include_file_descriptor_set` (in Nightly builds, run with -Z macro-backtrace for more info)

ollyde avatar Dec 30 '23 16:12 ollyde

are you calling this tonic::include_file_descriptor_set!("test") in the same crate that you have the descriptor set in?

LucioFranco avatar Jan 05 '24 16:01 LucioFranco

i somehow missed this thread even though i scoured the entire repo for references to reflection 😂 and ended up making my own issue (#1600). ive got a PR out as well with an example (#1601), but am happy to include some actual documentation for how to get it working from scratch without relying on cloning the tonic repo for its build process

grottohub avatar Jan 13 '24 14:01 grottohub