定时任务订阅模式
This commit is contained in:
1 parent
839386f0b4
commit
aa034f8669
14 files changed
+1143
-98
No files matched your search
+43
@@ -63,3 +63,46 @@ class ScheduledTaskStore(ABC):
|
||||
@abstractmethod
|
||||
async def update_delivery_profile(self, user_id: str, data: dict[str, Any]) -> dict[str, Any]:
|
||||
raise NotImplementedError
|
||||
|
||||
# --- Publish / subscribe ---
|
||||
|
||||
@abstractmethod
|
||||
async def get_task_any(self, task_id: str) -> dict[str, Any] | None:
|
||||
"""Return a task by id without restricting by owner. Used for publish/subscribe lookups."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_run_any(self, run_id: str) -> dict[str, Any] | None:
|
||||
"""Return a run by id without restricting by owner. Used for subscriber visibility."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def set_task_published(self, task_id: str, owner_user_id: str, *, published: bool) -> dict[str, Any] | None:
|
||||
"""Toggle published flag. Returns updated task or ``None`` if missing / not owned."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_published_tasks(self, *, limit: int = 50, offset: int = 0) -> list[dict[str, Any]]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_subscribed_tasks(self, user_id: str) -> list[dict[str, Any]]:
|
||||
"""Return tasks the user has subscribed to. Each item carries ``_subscription`` dict."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_subscription(self, task_id: str, user_id: str) -> dict[str, Any] | None:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def upsert_subscription(self, task_id: str, user_id: str, *, notify_element: bool) -> dict[str, Any]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def delete_subscription(self, task_id: str, user_id: str) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_notify_subscribers(self, task_id: str) -> list[dict[str, Any]]:
|
||||
"""Subscribers with ``notify_element=True`` for the given task."""
|
||||
raise NotImplementedError
|
||||
Reference in new issue
Block a user