Hi
I am fairly new to GRPC with Python
I wanted to explore reflection and followed the links provided above.
For testing purposes I create a simple test receiving an Id and returning
an associated result.
It works perfectly if I use generated code. Now trying to inspect the
server and get the services and instantiate dynamically the logic, I
struggle a bit more.
Using snippet like:
reflection_db = ProtoReflectionDescriptorDatabase(channel)
desc_pool = DescriptorPool(reflection_db)
services = reflection_db.get_services()
service = desc_pool.FindServiceByName(xxx)
for m in service.methods:
input_type = m.input_type
and with
request = MessageFactory(desc_pool).GetPrototype(input_type)()
I can build a request
I struggle to instantiate the service and call it with request:
I tried things like:
stub = GeneratedServiceStubType(service.name, (),
{GeneratedServiceStubType._DESCRIPTOR_KEY:service })
and then stub.<<myMethod>>(request) but it fails. I need to pass other
params but no real clue
The final purpose is to a kind of getAttr(stub,methode.name, parms)
I looked at code/googled but failed to find any helpful content
Thanks for any help
Cheers
Pascal
On Tuesday, 7 April 2020 at 19:12:10 UTC+2 Lidi Zheng wrote:
> I don't have a specific example for reflection.proto. It is a gRPC
> service. All the messages are defined with comments.
> The hard part is FileDescriptorProto, which is defined at
> https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto
> .
>
> On Mon, Apr 6, 2020 at 11:09 PM Louis Yang <[email protected]> wrote:
>
>> thanks, could you provide some example for using relection.proto?
>>
>> On Tuesday, 7 April 2020 06:51:56 UTC+8, Lidi Zheng wrote:
>>>
>>> There is a grpcio-reflection package that enables reflection services
>>> for servers. See example:
>>> https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_server_with_reflection.py
>>> .
>>>
>>> For client-side checking services list, here is the proto definition for
>>> service reflection API:
>>> https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto
>>> You can get all the details in the descriptor proto.
>>> Another option is using the CLI tool:
>>> https://github.com/fullstorydev/grpcurl.
>>>
>>> On Sat, Apr 4, 2020 at 8:21 PM Louis Yang <[email protected]> wrote:
>>>
>>>>
>>>> Like grpcox tool,
>>>>
>>>> Given a service endpoint: 1.2.3.4:50001, return the all services list
>>>> and rpc api under these services
>>>> is there an existing api for this in grpc-python?
>>>>
>>>> --
>>>> 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 [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/grpc-io/005f21b7-76ef-48fa-9be5-f270b52adf9b%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/grpc-io/005f21b7-76ef-48fa-9be5-f270b52adf9b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/grpc-io/51654a95-e257-42d1-a2b3-80e255ef74c8%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/grpc-io/51654a95-e257-42d1-a2b3-80e255ef74c8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/2927a3f6-a9f5-4e2d-af04-f43a4353abb9n%40googlegroups.com.