Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
506 changes: 506 additions & 0 deletions conformance/test/gen/connectrpc/conformance/v1/service_connect.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're maybe missing the /**/* in our own .gitattributes to properly mark these files as generated (think this approach in protobuf-py should work).

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from connectrpc.errors import ConnectError
from connectrpc.method import IdempotencyLevel, MethodInfo
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
from protobuf import DescService

from . import reflection_pb
from .reflection_pb import ServerReflectionRequest, ServerReflectionResponse

if TYPE_CHECKING:
Expand All @@ -26,9 +28,18 @@


class ServerReflection(Protocol):
""""""
def server_reflection_info(self, request: AsyncIterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> AsyncIterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

@classmethod
def desc(cls) -> DescService:
"""Returns the descriptor for this service."""
return next(s for s in reflection_pb.desc().services if s.type_name == 'grpc.reflection.v1.ServerReflection')

class ServerReflectionASGIApplication(ConnectASGIApplication[ServerReflection]):
def __init__(
Expand Down Expand Up @@ -67,13 +78,18 @@ def path(self) -> str:


class ServerReflectionClient(ConnectClient):
""""""
def server_reflection_info(
self,
request: AsyncIterator[ServerReflectionRequest],
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> AsyncIterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
return self.execute_bidi_stream(
request=request,
method=MethodInfo(
Expand All @@ -88,9 +104,18 @@ def server_reflection_info(
)

class ServerReflectionSync(Protocol):
""""""
def server_reflection_info(self, request: Iterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> Iterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

@classmethod
def desc(cls) -> DescService:
"""Returns the descriptor for this service."""
return next(s for s in reflection_pb.desc().services if s.type_name == 'grpc.reflection.v1.ServerReflection')

class ServerReflectionWSGIApplication(ConnectWSGIApplication):
def __init__(
Expand Down Expand Up @@ -127,13 +152,18 @@ def path(self) -> str:


class ServerReflectionClientSync(ConnectClientSync):
""""""
def server_reflection_info(
self,
request: Iterator[ServerReflectionRequest],
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> Iterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
return self.execute_bidi_stream(
request=request,
method=MethodInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from connectrpc.errors import ConnectError
from connectrpc.method import IdempotencyLevel, MethodInfo
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
from protobuf import DescService

from . import reflection_pb
from .reflection_pb import ServerReflectionRequest, ServerReflectionResponse

if TYPE_CHECKING:
Expand All @@ -26,9 +28,18 @@


class ServerReflection(Protocol):
""""""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should skip completely empty docstrings?

def server_reflection_info(self, request: AsyncIterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> AsyncIterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

@classmethod
def desc(cls) -> DescService:
"""Returns the descriptor for this service."""
return next(s for s in reflection_pb.desc().services if s.type_name == 'grpc.reflection.v1alpha.ServerReflection')

class ServerReflectionASGIApplication(ConnectASGIApplication[ServerReflection]):
def __init__(
Expand Down Expand Up @@ -67,13 +78,18 @@ def path(self) -> str:


class ServerReflectionClient(ConnectClient):
""""""
def server_reflection_info(
self,
request: AsyncIterator[ServerReflectionRequest],
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> AsyncIterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
return self.execute_bidi_stream(
request=request,
method=MethodInfo(
Expand All @@ -88,9 +104,18 @@ def server_reflection_info(
)

class ServerReflectionSync(Protocol):
""""""
def server_reflection_info(self, request: Iterator[ServerReflectionRequest], ctx: RequestContext[ServerReflectionRequest, ServerReflectionResponse]) -> Iterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

@classmethod
def desc(cls) -> DescService:
"""Returns the descriptor for this service."""
return next(s for s in reflection_pb.desc().services if s.type_name == 'grpc.reflection.v1alpha.ServerReflection')

class ServerReflectionWSGIApplication(ConnectWSGIApplication):
def __init__(
Expand Down Expand Up @@ -127,13 +152,18 @@ def path(self) -> str:


class ServerReflectionClientSync(ConnectClientSync):
""""""
def server_reflection_info(
self,
request: Iterator[ServerReflectionRequest],
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> Iterator[ServerReflectionResponse]:
"""
The reflection service is structured as a bidirectional stream, ensuring
all related requests go to a single server.
"""
return self.execute_bidi_stream(
request=request,
method=MethodInfo(
Expand Down
Loading
Loading