I'm guessing you are interested in doing this with Java (since I see
"[grpc-java]" in the subject).

You can query the grpc ServiceDescriptor for its "schema descriptor". For
proto-generated services, this will be a ProtoFileDescriptorSupplier, that
provides access to the FileDescriptor, which in turn contains everything
you're looking for.

The slight trick is that the interceptor, with each call, only sees a
MethodDescriptor for the method being invoked, which does not appear to
have a reference back to its enclosing ServiceDescriptor. So you'd need to
construct a "sidecar" map that allows access to the service descriptors
from the interceptor(s).

Here's a gist that demonstrates this:
https://gist.github.com/jhump/e8f67087ec5a3918f7b270a4a2b83516 (the sidecar
map is the MethodOptionsRegistry).

(Word of warning: I have not tried to actually compile and run the gist, so
you may find some small errors. But it should at least be instructive in
showing everything you actually need.)



----
*Josh Humphries*
jh...@bluegosling.com

On Tue, Jul 18, 2017 at 1:40 PM, ran.bi via grpc.io <
grpc-io@googlegroups.com> wrote:

> What's the best way to get custom method option data (
> https://developers.google.com/protocol-buffers/docs/proto3#custom_options)
> from server interceptors?
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to grpc-io+unsubscr...@googlegroups.com.
> To post to this group, send email to grpc-io@googlegroups.com.
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/8756e7c5-a164-4ad3-b4d9-0d4f7b5d2239%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/8756e7c5-a164-4ad3-b4d9-0d4f7b5d2239%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAO78j%2BLX_ogZUoZsfDcKoiTueF%3D8JSs%3DaLT616kT3kuNOAQx8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to