18 lines
577 B
Python
18 lines
577 B
Python
"""Notification handling."""
|
|
import asyncio
|
|
|
|
class NotificationService:
|
|
"""Handles job completion notifications."""
|
|
def __init__(self):
|
|
self.subscribers = []
|
|
|
|
def subscribe(self, callback) -> None:
|
|
"""Add a notification callback."""
|
|
self.subscribers.append(callback)
|
|
|
|
async def notify(self, job_id: str, result: dict) -> None:
|
|
"""Notify all subscribers of job completion."""
|
|
for callback in self.subscribers:
|
|
# Currently: no routing strategy, calls directly
|
|
await callback(job_id, result)
|