Skip to content

Commit 36824bc

Browse files
authored
Revert "Revert "Revert "Add Python Reflection Client (#28443)" (#28878)" (#28879)" (#29023)
This reverts commit cf9be3d.
1 parent 851df6d commit 36824bc

File tree

8 files changed

+16
-464
lines changed

8 files changed

+16
-464
lines changed

doc/python/server_reflection.md

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -49,61 +49,6 @@ is working properly by using the [`grpc_cli` command line tool]:
4949
please refer to the [`grpc_cli` documentation] and the
5050
[C++ Server Reflection Tutorial].
5151

52-
53-
## Use Server Reflection in a Python client
54-
55-
Server Reflection can be used by clients to get information about gRPC services
56-
at runtime. We've provided a descriptor database called
57-
[ProtoReflectionDescriptorDatabase](../../src/python/grpcio_reflection/v1alpha/proto_reflection_descriptor_database.h)
58-
which implements the
59-
[DescriptorDatabase](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_database.html#google.protobuf.descriptor_database.DescriptorDatabase)
60-
interface. It manages the communication between clients and reflection services
61-
and the storage of received information. Clients can use it as using a local
62-
descriptor database.
63-
64-
- To use Server Reflection with ProtoReflectionDescriptorDatabase, first
65-
initialize an instance with a channel.
66-
67-
```Python
68-
import grpc
69-
from grpc_reflection.v1alpha.proto_reflection_descriptor_database import ProtoReflectionDescriptorDatabase
70-
71-
channel = grpc.secure_channel(server_address, creds)
72-
reflection_db = ProtoReflectionDescriptorDatabase(channel)
73-
```
74-
75-
- Then use this instance to feed a
76-
[DescriptorPool](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool).
77-
78-
```Python
79-
from google.protobuf.descriptor_pool import DescriptorPool
80-
81-
desc_pool = DescriptorPool(reflection_db)
82-
```
83-
84-
- Example usage of this descriptor pool:
85-
86-
* Get Service/method descriptors.
87-
88-
```Python
89-
service_desc = desc_pool.FindServiceByName("helloworld.Greeter")
90-
method_desc = service_desc.FindMethodByName("helloworld.Greeter.SayHello")
91-
```
92-
93-
* Get message type descriptors and create messages dynamically.
94-
95-
```Python
96-
request_desc = desc_pool.FindMessageTypeByName("helloworld.HelloRequest")
97-
request = MessageFactory(desc_pool).GetPrototype(request_desc)()
98-
```
99-
100-
- You can also use the Reflection Database to list all the services:
101-
102-
```Python
103-
services = reflection_db.get_services()
104-
```
105-
106-
10752
## Additional Resources
10853

10954
The [Server Reflection Protocol] provides detailed

doc/python/sphinx/grpc_reflection.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,4 @@ Refer to the GitHub `reflection example <https://github.com/grpc/grpc/blob/maste
1616
Module Contents
1717
---------------
1818

19-
Server-side
20-
...........
21-
2219
.. automodule:: grpc_reflection.v1alpha.reflection
23-
24-
Client-side
25-
...........
26-
27-
.. automodule:: grpc_reflection.v1alpha.proto_reflection_descriptor_database
28-
:member-order: bysource

doc/server_reflection_tutorial.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,3 @@ descriptor database.
187187
google::protobuf::Message* request = dmf.GetPrototype(request_desc)->New();
188188
```
189189

190-
## Use Server Reflection in a Python client
191-
192-
See [Python Server Reflection](python/server_reflection.md).
193-

src/python/grpcio_reflection/grpc_reflection/v1alpha/proto_reflection_descriptor_database.py

Lines changed: 0 additions & 222 deletions
This file was deleted.

src/python/grpcio_tests/tests/reflection/BUILD.bazel

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package(default_visibility = ["//visibility:public"])
1717

1818
py_test(
1919
name = "_reflection_servicer_test",
20-
size = "small",
20+
size = "medium",
2121
srcs = ["_reflection_servicer_test.py"],
2222
imports = ["../../"],
2323
main = "_reflection_servicer_test.py",
@@ -32,23 +32,3 @@ py_test(
3232
requirement("protobuf"),
3333
],
3434
)
35-
36-
py_test(
37-
name = "_reflection_client_test",
38-
size = "small",
39-
srcs = ["_reflection_client_test.py"],
40-
imports = ["../../"],
41-
main = "_reflection_client_test.py",
42-
python_version = "PY3",
43-
deps = [
44-
"//src/proto/grpc/testing:empty_py_pb2",
45-
"//src/proto/grpc/testing:py_messages_proto",
46-
"//src/proto/grpc/testing:test_py_pb2_grpc",
47-
"//src/proto/grpc/testing/proto2:empty2_extensions_proto",
48-
"//src/proto/grpc/testing/proto2:empty2_proto",
49-
"//src/python/grpcio/grpc:grpcio",
50-
"//src/python/grpcio_reflection/grpc_reflection/v1alpha:grpc_reflection",
51-
"//src/python/grpcio_tests/tests/unit:test_common",
52-
requirement("protobuf"),
53-
],
54-
)

0 commit comments

Comments
 (0)