Coverage for object_streams/transports/base.py: 100%
14 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 17:07 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 17:07 +0000
1"""Transport protocol used by concrete WebSocket or message adapters."""
3from __future__ import annotations
5from typing import Any
6from typing import Protocol
8from object_streams.events import StreamEvent
9from object_streams.subscriptions import ResyncRequired
10from object_streams.subscriptions import SubscriptionRequest
13__all__ = ("Transport",)
16class Transport(Protocol):
17 async def prepare_subscription(self, subscription: SubscriptionRequest) -> None:
18 """Prepare transport routing before the subscription is acknowledged."""
20 async def send_subscribed(self, subscription: SubscriptionRequest) -> None:
21 """Send a subscription acknowledgement."""
23 async def send_unsubscribed(self, subscription_id: str) -> None:
24 """Send an unsubscribe acknowledgement."""
26 async def send_event(self, event: StreamEvent) -> None:
27 """Send a stream event."""
29 async def send_resync(self, resync: ResyncRequired) -> None:
30 """Send a subscription-level resync instruction."""
32 async def send_error(self, code: str, message: str, *, details: Any = None) -> None:
33 """Send a protocol error."""