Add idiomatic documentation to Go, Java, Python, and Rust clients
This commit is contained in:
@@ -25,6 +25,7 @@ class GatewayClient:
|
||||
stub: Any,
|
||||
channel: grpc.aio.Channel | None = None,
|
||||
) -> None:
|
||||
"""Initialize the client with resolved options and a gRPC stub."""
|
||||
self.options = options
|
||||
self.raw_stub = stub
|
||||
self._channel = channel
|
||||
@@ -63,9 +64,11 @@ class GatewayClient:
|
||||
)
|
||||
|
||||
async def __aenter__(self) -> "GatewayClient":
|
||||
"""Return self to support ``async with`` usage."""
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_exc_info: object) -> None:
|
||||
"""Close the client when leaving an ``async with`` block."""
|
||||
await self.close()
|
||||
|
||||
async def close(self) -> None:
|
||||
@@ -99,6 +102,7 @@ class GatewayClient:
|
||||
return Session(client=self, session_id=reply.session_id, open_reply=reply)
|
||||
|
||||
async def open_session_raw(self, request: pb.OpenSessionRequest) -> pb.OpenSessionReply:
|
||||
"""Send an `OpenSession` RPC and return the raw reply."""
|
||||
reply = await self._unary("open session", self.raw_stub.OpenSession, request)
|
||||
ensure_protocol_success("open session", reply.protocol_status, reply)
|
||||
return reply
|
||||
@@ -107,11 +111,13 @@ class GatewayClient:
|
||||
self,
|
||||
request: pb.CloseSessionRequest,
|
||||
) -> pb.CloseSessionReply:
|
||||
"""Send a `CloseSession` RPC and return the raw reply."""
|
||||
reply = await self._unary("close session", self.raw_stub.CloseSession, request)
|
||||
ensure_protocol_success("close session", reply.protocol_status, reply)
|
||||
return reply
|
||||
|
||||
async def invoke_raw(self, request: pb.MxCommandRequest) -> pb.MxCommandReply:
|
||||
"""Send an `Invoke` RPC and return the raw reply."""
|
||||
reply = await self._unary("invoke", self.raw_stub.Invoke, request)
|
||||
ensure_protocol_success("invoke", reply.protocol_status, reply)
|
||||
return reply
|
||||
|
||||
Reference in New Issue
Block a user