From 6d7ba58f880be618ade07f8ea080fe8c4bf8a896 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Wed, 3 Apr 2024 03:10:44 -0400 Subject: venv --- .../litestar/channels/backends/base.py | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 venv/lib/python3.11/site-packages/litestar/channels/backends/base.py (limited to 'venv/lib/python3.11/site-packages/litestar/channels/backends/base.py') diff --git a/venv/lib/python3.11/site-packages/litestar/channels/backends/base.py b/venv/lib/python3.11/site-packages/litestar/channels/backends/base.py new file mode 100644 index 0000000..ce7ee81 --- /dev/null +++ b/venv/lib/python3.11/site-packages/litestar/channels/backends/base.py @@ -0,0 +1,41 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import AsyncGenerator, Iterable + + +class ChannelsBackend(ABC): + @abstractmethod + async def on_startup(self) -> None: + """Called by the plugin on application startup""" + ... + + @abstractmethod + async def on_shutdown(self) -> None: + """Called by the plugin on application shutdown""" + ... + + @abstractmethod + async def publish(self, data: bytes, channels: Iterable[str]) -> None: + """Publish the message ``data`` to all ``channels``""" + ... + + @abstractmethod + async def subscribe(self, channels: Iterable[str]) -> None: + """Start listening for events on ``channels``""" + ... + + @abstractmethod + async def unsubscribe(self, channels: Iterable[str]) -> None: + """Stop listening for events on ``channels``""" + ... + + @abstractmethod + def stream_events(self) -> AsyncGenerator[tuple[str, bytes], None]: + """Return a generator, iterating over events of subscribed channels as they become available""" + ... + + @abstractmethod + async def get_history(self, channel: str, limit: int | None = None) -> list[bytes]: + """Return the event history of ``channel``, at most ``limit`` entries""" + ... -- cgit v1.2.3