Git Product home page Git Product logo

Comments (2)

jhump avatar jhump commented on June 27, 2024

@HT808s, I think this is a great idea. The only reason grpcurl doesn't show it now was more-or-less pure oversight.

I think it will be a bit tricky though. The Details() method of status won't be useful because it uses the default logic in github.com/golang/protobuf/ptypes to unmarshal the Any messages, which relies on linking generated code into the binary. Since grpcurl does not link with any such generated code (except for the few google.protobuf proto packages for descriptors and well-known types), you'll most likely just get a list of errors about not being able to resolve the actual message type.

So what I think is actually necessary follows:

  1. Get the underlying google.protobuf.Any messages for the details.
  2. For each one, parse out the fully-qualified message name. Use the DescriptorSource to get descriptor details for that message type (this will ask the server via the reflection interface or look at local proto files).
  3. If you can get a descriptor, then from there you can use functions in github.com/jhump/protoreflect/dynamic to unmarshal the message and then format it as JSON.
  4. If you cannot get a descriptor, then I think we should just show the String()-ified proto or perhaps a custom JSON form that shows the @type attribute but then also shows a @value attribute as the base64-encoded binary value.

If you're still willing to tackle a PR, I'll review it. But I can also probably get to this sometime this week, maybe even later today.

from grpcurl.

HT808s avatar HT808s commented on June 27, 2024

@jhump Thanks for your detailed reply!

I am not familiar with the inner of proto messages unmarshaling so this was instructive!
It's fine by me if you want to tackle it!

from grpcurl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.