asyncpg

class litestar.channels.backends.asyncpg.AsyncPgChannelsBackend[source]

Bases: ChannelsBackend

__init__(dsn: str) None[source]
__init__(*, make_connection: Callable[[], Awaitable[asyncpg.Connection]]) None
async on_startup() None[source]

Called by the plugin on application startup

async on_shutdown() None[source]

Called by the plugin on application shutdown

async publish(data: bytes, channels: Iterable[str]) None[source]

Publish the message data to all channels

async subscribe(channels: Iterable[str]) None[source]

Start listening for events on channels

async unsubscribe(channels: Iterable[str]) None[source]

Stop listening for events on channels

async stream_events() AsyncGenerator[tuple[str, bytes], None][source]

Return a generator, iterating over events of subscribed channels as they become available

async get_history(channel: str, limit: int | None = None) list[bytes][source]

Return the event history of channel, at most limit entries