feat(perception): add scoped stream control and bounded clock observations
This commit is contained in:
@@ -149,7 +149,14 @@ class GrpcStreamEndpoint:
|
||||
if self.active is not None and self.active[0] == epoch:
|
||||
self.active[1].finish()
|
||||
|
||||
async def serve(self, address: str, *, certificate: bytes, private_key: bytes) -> Any:
|
||||
async def serve(
|
||||
self,
|
||||
address: str,
|
||||
*,
|
||||
certificate: bytes,
|
||||
private_key: bytes,
|
||||
control_handlers: tuple[Any, ...] = (),
|
||||
) -> Any:
|
||||
if not certificate or not private_key:
|
||||
raise ValueError("TLS identity is required")
|
||||
server = grpc.aio.server(
|
||||
@@ -158,7 +165,11 @@ class GrpcStreamEndpoint:
|
||||
("grpc.max_receive_message_length", INPUT_CHUNK),
|
||||
("grpc.max_send_message_length", MAX_REPLY),
|
||||
),
|
||||
maximum_concurrent_rpcs=2,
|
||||
# aio reserves its next accept before awaiting a request. Leave
|
||||
# one bounded accept slot beside Exchange + a completing Poll;
|
||||
# otherwise the next Poll can inherit a stale "limit exceeded".
|
||||
# Data ownership still admits exactly one Exchange, never 2 GPUs.
|
||||
maximum_concurrent_rpcs=3 if control_handlers else 2,
|
||||
compression=grpc.Compression.NoCompression,
|
||||
)
|
||||
server.add_generic_rpc_handlers(
|
||||
@@ -166,6 +177,7 @@ class GrpcStreamEndpoint:
|
||||
grpc.method_handlers_generic_handler(
|
||||
SERVICE, {"Exchange": grpc.stream_stream_rpc_method_handler(self.exchange)}
|
||||
),
|
||||
*control_handlers,
|
||||
)
|
||||
)
|
||||
port = server.add_secure_port(
|
||||
|
||||
Reference in New Issue
Block a user