Code Monkey home page Code Monkey logo

Comments (4)

siddontang avatar siddontang commented on June 30, 2024 1

Hi @autodidaddict

We have no plan for this now, but this is a cool suggestion.

Can you give us some ideas about what needs to do if we support this feature?

from grpc-rs.

autodidaddict avatar autodidaddict commented on June 30, 2024

Reflection is supported in the Go and .NET SDKs for gRPC, I'm not sure about the other SDKs since I don't use them. But it's fairly straightforward - they provide an implementation of the reflection service PROTO and then provide some way for developers to host this reflection service alongside their actual service on the same port. With this in place, we can use tools like grpcurl to query, identify, and obtain metadata on our services. Having this reflection ability makes our services far more tooling-friendly, which in turn lowers the barrier to resistance of gRPC over something like REST.

The reflection service is basically just this:

service ServerReflection { 
  rpc ServerReflectionInfo(stream ServerReflectionRequest)
      returns (stream ServerReflectionResponse);
}

If you look at the other SDK implementations, you'll see that they basically just do a switch on the request type and return the appropriate data. In the .NET implementation, there is a descriptor generated into the gRPC C# file which provides access to metadata and the original proto IDL, and these descriptors are then passed to the reflection service implementation that comes with the SDK.

Here is a link to the .NET service implementation of Reflection.

Here is where the Go SDK implements reflection.

from grpc-rs.

autodidaddict avatar autodidaddict commented on June 30, 2024

Here's a list of the operations that a client can request of a reflection service (you'll see this as an enum in the Reflection proto):

  • Ask for a proto file by filename
  • Find a proto file that contains the supplied fully-qualified symbol name
  • Find a proto file that defines an extension that extends the given message type with the given field number
  • Find the tag numbers used by all known extensions of a message type
  • List the names of registered services

Some SDKs return StatusCode::NOTIMPLEMENTED for some of these (.NET doesn't implement "file containing extension" and "all extensions" request types)

from grpc-rs.

autodidaddict avatar autodidaddict commented on June 30, 2024

TL;DR - if the service implementation has access to a map of filename->proto IDL, then it can support the bare minimum reflection functionality

from grpc-rs.

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.