BaseStreamingService
Interface a streaming service (websockets or webrtc) implements so the supervisor can start, stop, and route to either interchangeably.
Attributes
attributemode= nameFunctions
func__init__(self, name) -> NoneSource Code
def __init__(self, name: str) -> None:
self.mode = nameparamselfparamnamestrReturns
Nonefuncstart(self) -> NoneSet up resources and run the service's loops until stopped.
Source Code
@abstractmethod
async def start(self) -> None:
"""Set up resources and run the service's loops until stopped."""paramselfReturns
Nonefuncstop(self) -> NoneClean up resources and stop the service's loops.
Source Code
@abstractmethod
async def stop(self) -> None:
"""Clean up resources and stop the service's loops."""paramselfReturns
Nonefuncregister_routes(self, api_prefix, main_router) -> NoneRegister the service's absolute paths directly on the main router.
Source Code
@abstractmethod
def register_routes(self, api_prefix: str, main_router: web.UrlDispatcher) -> None:
"""Register the service's absolute paths directly on the main router.
Args:
api_prefix: Deployment subfolder prefix (empty when serving at root).
main_router: The application's router to register routes on.
"""
passparamselfparamapi_prefixstrDeployment subfolder prefix (empty when serving at root).
parammain_routerweb.UrlDispatcherThe application's router to register routes on.
Returns
Nonefuncuplink_session_conns(self) -> List[Tuple[Any, Optional[str], Optional[str]]](websocket, session token, peer ip) per connected client
session, for upload uplink gauging (UplinkGauge).
The websocket must send ping() frames, and the service's message
loop must run with autoping off, answer PING itself, and hand every
PONG to note_pong — the gauge's clock is dead without that. Both
transports implement this; an upload gauged on one side but not the
other is a parity bug. Default: nothing to gauge.
Source Code
def uplink_session_conns(self) -> List[Tuple[Any, Optional[str], Optional[str]]]:
"""``(websocket, session token, peer ip)`` per connected client
session, for upload uplink gauging (`UplinkGauge`).
The websocket must send ``ping()`` frames, and the service's message
loop must run with autoping off, answer PING itself, and hand every
PONG to `note_pong` — the gauge's clock is dead without that. Both
transports implement this; an upload gauged on one side but not the
other is a parity bug. Default: nothing to gauge.
"""
return []paramselfReturns
typing.List[typing.Tuple[typing.Any, typing.Optional[str], typing.Optional[str]]]