Events
Event listener using Postgres LISTEN for pyfetcher.events.
-
class pyfetcher.events.listener.EventListener(config=None)[source]
Listens for Postgres NOTIFY events on specified channels.
Uses a raw asyncpg connection (not SQLAlchemy) for LISTEN since
SQLAlchemy’s async session doesn’t expose notification listeners.
- Parameters:
config (PyfetcherConfig | None) – Application configuration with database URL.
-
on(channel, handler)[source]
Register a handler for a channel.
- Parameters:
channel (str) – The channel to listen on.
handler (Callable[[str], Coroutine[Any, Any, None]]) – Async callable receiving the notification payload.
- Return type:
None
-
async start()[source]
Start listening on all registered channels.
Runs indefinitely, dispatching notifications to registered
handlers. Call stop() to shut down.
- Return type:
None
-
async stop()[source]
Stop listening and close the connection.
- Return type:
None
NOTIFY channel constants for pyfetcher.events.
-
class pyfetcher.events.channels.Channels[source]
Postgres NOTIFY channel names for pipeline stages.