connectrpc-grpcreflect 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,219 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity granting the License.
13
+
14
+ "Legal Entity" shall mean the union of the acting entity and all
15
+ other entities that control, are controlled by, or are under common
16
+ control with that entity. For the purposes of this definition,
17
+ "control" means (i) the power, direct or indirect, to cause the
18
+ direction or management of such entity, whether by contract or
19
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity
23
+ exercising permissions granted by this License.
24
+
25
+ "Source" shall mean the preferred form for making modifications,
26
+ including but not limited to software source code, documentation
27
+ source, and configuration files.
28
+
29
+ "Object" shall mean any form resulting from mechanical
30
+ transformation or translation of a Source form, including but
31
+ not limited to compiled object code, generated documentation,
32
+ and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or
35
+ Object form, made available under the License, as indicated by a
36
+ copyright notice that is included in or attached to the work
37
+ (which shall not include communications that are solely limited to
38
+ and are identified as being limited to a portion of the work).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based upon (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and derivative works thereof.
47
+
48
+ "Contributor" shall mean Licensor and any individual or Legal Entity
49
+ on behalf of whom a Contribution has been made to Licensor. For the
50
+ purposes of this definition, "Contribution" shall mean any work of
51
+ authorship, including the original version of the Work and any
52
+ modifications or additions to that Work or Derivative Works thereof,
53
+ that is intentionally submitted to Licensor for inclusion in the Work
54
+ by the copyright owner or by an individual or Legal Entity authorized
55
+ to submit on behalf of the copyright owner. For the purposes of this
56
+ definition, "submitted" means any form of electronic, verbal, or
57
+ written communication sent to the Licensor or its representatives,
58
+ including but not limited to communication on electronic mailing
59
+ lists, source code control systems, and issue tracking systems that
60
+ are managed by, or on behalf of, the Licensor for the purpose of
61
+ discussing and improving the Work, but excluding communication that
62
+ is conspicuously marked or otherwise designated in writing by the
63
+ copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been made to Licensor. For the
67
+ purposes of this definition, "Contribution" shall mean any work of
68
+ authorship, including the original version of the Work and any
69
+ modifications or additions to that Work or Derivative Works thereof,
70
+ that is intentionally submitted to Licensor for inclusion in the Work
71
+ by the copyright owner or by an individual or Legal Entity authorized
72
+ to submit on behalf of the copyright owner. For the purposes of this
73
+ definition, "submitted" means any form of electronic, verbal, or
74
+ written communication sent to the Licensor or its representatives,
75
+ including but not limited to communication on electronic mailing
76
+ lists, source code control systems, and issue tracking systems that
77
+ are managed by, or on behalf of, the Licensor for the purpose of
78
+ discussing and improving the Work, but excluding communication that
79
+ is conspicuously marked or otherwise designated in writing by the
80
+ copyright owner as "Not a Contribution."
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to use, reproduce, modify, distribute, and prepare
86
+ Derivative Works of, publicly display, publicly perform, sublicense,
87
+ and distribute the Work and such Derivative Works in source or object
88
+ form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in source or object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, trademark, patent,
119
+ attribution and other notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright notice to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Support. Unless agreed to otherwise,
183
+ no Contributor is required to provide support, warranties,
184
+ indemnities, or other obligations to You. However, if You elect to
185
+ provide support, warranties, indemnities, or other obligations to
186
+ one or more recipients of Covered Software, You may do so only on
187
+ Your own behalf, and not on behalf of any Contributor. You must make
188
+ it absolutely clear that any such warranty, support, indemnity, or
189
+ other obligation is offered by You alone, and You hereby agree to
190
+ indemnify every Contributor for any liability incurred by such
191
+ Contributor as a result of warranty, support, indemnity or other
192
+ obligation You offer.
193
+
194
+ END OF TERMS AND CONDITIONS
195
+
196
+ APPENDIX: How to apply the Apache License to your work.
197
+
198
+ To apply the Apache License to your work, attach the following
199
+ boilerplate notice, with the fields enclosed by brackets "[]"
200
+ replaced with your own identifying information. (Don't include
201
+ the brackets!) The text should be enclosed in the appropriate
202
+ comment syntax for the file format. We also recommend that a
203
+ file or class name and description of purpose be included on the
204
+ same "printed page" as the copyright notice for easier
205
+ identification within third-party archives.
206
+
207
+ Copyright 2025 The Connect Authors
208
+
209
+ Licensed under the Apache License, Version 2.0 (the "License");
210
+ you may not use this file except in compliance with the License.
211
+ You may obtain a copy of the License at
212
+
213
+ http://www.apache.org/licenses/LICENSE-2.0
214
+
215
+ Unless required by applicable law or agreed to in writing, software
216
+ distributed under the License is distributed on an "AS IS" BASIS,
217
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ See the License for the specific language governing permissions and
219
+ limitations under the License.
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: connectrpc-grpcreflect
3
+ Version: 0.1.0
4
+ Summary: gRPC reflection for connectrpc
5
+ Keywords: connect-py,connectrpc,grpc
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: System :: Networking
20
+ Requires-Dist: connectrpc>=0.11.0
21
+ Maintainer: Anuraag Agrawal, Spencer Nelson, Stefan VanBuren, Yasushi Itoh
22
+ Maintainer-email: Anuraag Agrawal <anuraaga@gmail.com>, Spencer Nelson <spencer@firetiger.com>, Stefan VanBuren <stefan@vanburen.xyz>, Yasushi Itoh <i2y.may.roku@gmail.com>
23
+ Requires-Python: >=3.10
24
+ Project-URL: Homepage, https://github.com/connectrpc/connect-py
25
+ Project-URL: Issues, https://github.com/connectrpc/connect-py/issues
26
+ Project-URL: Repository, https://github.com/connectrpc/connect-py
27
+ Description-Content-Type: text/markdown
28
+
29
+ # connectrpc-grpcreflect
30
+
31
+ gRPC reflection services to support tools such as [`buf curl`](https://buf.build/docs/curl/)
32
+ that query servers without knowing their schema.
33
+
34
+ The services are standard Connect services that you use as normal.
35
+
36
+ ## Example
37
+
38
+ ```python
39
+ from typing import cast
40
+
41
+ from connectrpc_grpcreflect import (
42
+ ServerReflectionASGIApplication,
43
+ ServerReflectionService,
44
+ )
45
+ from starlette.applications import Starlette
46
+ from starlette.routing import Mount
47
+ from starlette.types import ASGIApp
48
+
49
+ from .gen.connectrpc.eliza.v1 import eliza_pb
50
+ from .gen.connectrpc.eliza.v1.eliza_connect import ElizaServiceASGIApplication
51
+ from .service import ElizaService
52
+
53
+ eliza_app = ElizaServiceASGIApplication(ElizaService())
54
+ reflection_app = ServerReflectionASGIApplication(
55
+ ServerReflectionService(eliza_pb.desc())
56
+ )
57
+
58
+ app = Starlette(
59
+ routes=[
60
+ Mount(eliza_app.path, cast(ASGIApp, eliza_app)),
61
+ Mount(reflection_app.path, cast(ASGIApp, reflection_app)),
62
+ ]
63
+ )
64
+ ```
@@ -0,0 +1,36 @@
1
+ # connectrpc-grpcreflect
2
+
3
+ gRPC reflection services to support tools such as [`buf curl`](https://buf.build/docs/curl/)
4
+ that query servers without knowing their schema.
5
+
6
+ The services are standard Connect services that you use as normal.
7
+
8
+ ## Example
9
+
10
+ ```python
11
+ from typing import cast
12
+
13
+ from connectrpc_grpcreflect import (
14
+ ServerReflectionASGIApplication,
15
+ ServerReflectionService,
16
+ )
17
+ from starlette.applications import Starlette
18
+ from starlette.routing import Mount
19
+ from starlette.types import ASGIApp
20
+
21
+ from .gen.connectrpc.eliza.v1 import eliza_pb
22
+ from .gen.connectrpc.eliza.v1.eliza_connect import ElizaServiceASGIApplication
23
+ from .service import ElizaService
24
+
25
+ eliza_app = ElizaServiceASGIApplication(ElizaService())
26
+ reflection_app = ServerReflectionASGIApplication(
27
+ ServerReflectionService(eliza_pb.desc())
28
+ )
29
+
30
+ app = Starlette(
31
+ routes=[
32
+ Mount(eliza_app.path, cast(ASGIApp, eliza_app)),
33
+ Mount(reflection_app.path, cast(ASGIApp, reflection_app)),
34
+ ]
35
+ )
36
+ ```
@@ -0,0 +1,31 @@
1
+ """Service implementations for the gRPC reflection service."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "ServerReflectionASGIApplication",
7
+ "ServerReflectionAlphaASGIApplication",
8
+ "ServerReflectionAlphaService",
9
+ "ServerReflectionAlphaServiceSync",
10
+ "ServerReflectionAlphaWSGIApplication",
11
+ "ServerReflectionService",
12
+ "ServerReflectionServiceSync",
13
+ "ServerReflectionWSGIApplication",
14
+ ]
15
+
16
+ from ._gen.grpc.reflection.v1.reflection_connect import (
17
+ ServerReflectionASGIApplication,
18
+ ServerReflectionWSGIApplication,
19
+ )
20
+ from ._gen.grpc.reflection.v1alpha.reflection_connect import (
21
+ ServerReflectionASGIApplication as ServerReflectionAlphaASGIApplication,
22
+ )
23
+ from ._gen.grpc.reflection.v1alpha.reflection_connect import (
24
+ ServerReflectionWSGIApplication as ServerReflectionAlphaWSGIApplication,
25
+ )
26
+ from ._service import (
27
+ ServerReflectionAlphaService,
28
+ ServerReflectionAlphaServiceSync,
29
+ ServerReflectionService,
30
+ ServerReflectionServiceSync,
31
+ )
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1,148 @@
1
+ # Generated from grpc/reflection/v1/reflection.proto. DO NOT EDIT.
2
+ # Generated by protoc-gen-connectrpc-py v0.11.0 with parameter "".
3
+ # ruff: noqa: PGH004
4
+ # ruff: noqa
5
+ # fmt: off
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Protocol, TYPE_CHECKING
10
+
11
+ from connectrpc.client import ConnectClient, ConnectClientSync
12
+ from connectrpc.code import Code
13
+ from connectrpc.errors import ConnectError
14
+ from connectrpc.method import IdempotencyLevel, MethodInfo
15
+ from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
16
+
17
+ from .reflection_pb import ServerReflectionRequest, ServerReflectionResponse
18
+
19
+ if TYPE_CHECKING:
20
+ from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Iterator, Mapping
21
+
22
+ from connectrpc.codec import Codec
23
+ from connectrpc.compression import Compression
24
+ from connectrpc.interceptor import Interceptor, InterceptorSync
25
+ from connectrpc.request import Headers, RequestContext
26
+
27
+
28
+ class ServerReflection(Protocol):
29
+ def server_reflection_info(self, request: AsyncIterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> AsyncIterator[ServerReflectionResponse]:
30
+ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
31
+
32
+
33
+ class ServerReflectionASGIApplication(ConnectASGIApplication[ServerReflection]):
34
+ def __init__(
35
+ self,
36
+ service: ServerReflection | AsyncGenerator[ServerReflection],
37
+ *,
38
+ interceptors: Iterable[Interceptor] = (),
39
+ read_max_bytes: int | None = None,
40
+ compressions: Iterable[Compression] | None = None,
41
+ codecs: Iterable[Codec] | None = None,
42
+ ) -> None:
43
+ super().__init__(
44
+ service=service,
45
+ endpoints=lambda svc: {
46
+ "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo": Endpoint.bidi_stream(
47
+ method=MethodInfo(
48
+ name="ServerReflectionInfo",
49
+ service_name="grpc.reflection.v1.ServerReflection",
50
+ input=ServerReflectionRequest,
51
+ output=ServerReflectionResponse,
52
+ idempotency_level=IdempotencyLevel.UNKNOWN,
53
+ ),
54
+ function=svc.server_reflection_info,
55
+ ),
56
+ },
57
+ interceptors=interceptors,
58
+ read_max_bytes=read_max_bytes,
59
+ compressions=compressions,
60
+ codecs=codecs,
61
+ )
62
+
63
+ @property
64
+ def path(self) -> str:
65
+ """Returns the URL path to mount the application to when serving multiple applications."""
66
+ return "/grpc.reflection.v1.ServerReflection"
67
+
68
+
69
+ class ServerReflectionClient(ConnectClient):
70
+ def server_reflection_info(
71
+ self,
72
+ request: AsyncIterator[ServerReflectionRequest],
73
+ *,
74
+ headers: Headers | Mapping[str, str] | None = None,
75
+ timeout_ms: int | None = None,
76
+ ) -> AsyncIterator[ServerReflectionResponse]:
77
+ return self.execute_bidi_stream(
78
+ request=request,
79
+ method=MethodInfo(
80
+ name="ServerReflectionInfo",
81
+ service_name="grpc.reflection.v1.ServerReflection",
82
+ input=ServerReflectionRequest,
83
+ output=ServerReflectionResponse,
84
+ idempotency_level=IdempotencyLevel.UNKNOWN,
85
+ ),
86
+ headers=headers,
87
+ timeout_ms=timeout_ms,
88
+ )
89
+
90
+ class ServerReflectionSync(Protocol):
91
+ def server_reflection_info(self, request: Iterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> Iterator[ServerReflectionResponse]:
92
+ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
93
+
94
+
95
+ class ServerReflectionWSGIApplication(ConnectWSGIApplication):
96
+ def __init__(
97
+ self,
98
+ service: ServerReflectionSync,
99
+ interceptors: Iterable[InterceptorSync] = (),
100
+ read_max_bytes: int | None = None,
101
+ compressions: Iterable[Compression] | None = None,
102
+ codecs: Iterable[Codec] | None = None,
103
+ ) -> None:
104
+ super().__init__(
105
+ endpoints={
106
+ "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo": EndpointSync.bidi_stream(
107
+ method=MethodInfo(
108
+ name="ServerReflectionInfo",
109
+ service_name="grpc.reflection.v1.ServerReflection",
110
+ input=ServerReflectionRequest,
111
+ output=ServerReflectionResponse,
112
+ idempotency_level=IdempotencyLevel.UNKNOWN,
113
+ ),
114
+ function=service.server_reflection_info,
115
+ ),
116
+ },
117
+ interceptors=interceptors,
118
+ read_max_bytes=read_max_bytes,
119
+ compressions=compressions,
120
+ codecs=codecs,
121
+ )
122
+
123
+ @property
124
+ def path(self) -> str:
125
+ """Returns the URL path to mount the application to when serving multiple applications."""
126
+ return "/grpc.reflection.v1.ServerReflection"
127
+
128
+
129
+ class ServerReflectionClientSync(ConnectClientSync):
130
+ def server_reflection_info(
131
+ self,
132
+ request: Iterator[ServerReflectionRequest],
133
+ *,
134
+ headers: Headers | Mapping[str, str] | None = None,
135
+ timeout_ms: int | None = None,
136
+ ) -> Iterator[ServerReflectionResponse]:
137
+ return self.execute_bidi_stream(
138
+ request=request,
139
+ method=MethodInfo(
140
+ name="ServerReflectionInfo",
141
+ service_name="grpc.reflection.v1.ServerReflection",
142
+ input=ServerReflectionRequest,
143
+ output=ServerReflectionResponse,
144
+ idempotency_level=IdempotencyLevel.UNKNOWN,
145
+ ),
146
+ headers=headers,
147
+ timeout_ms=timeout_ms,
148
+ )