diff --git a/silverback/application.py b/silverback/application.py index aec3d1e7..2691a98a 100644 --- a/silverback/application.py +++ b/silverback/application.py @@ -109,6 +109,9 @@ def __init__(self, settings: Settings | None = None): self._get_user_taskdata = self.__register_system_task( TaskType.SYSTEM_USER_TASKDATA, self.__get_user_taskdata_handler ) + self._get_user_all_taskdata = self.__register_system_task( + TaskType.SYSTEM_USER_ALL_TASKDATA, self.__get_user_all_taskdata_handler + ) def __register_system_task( self, task_type: TaskType, task_handler: Callable @@ -136,6 +139,9 @@ def __get_user_taskdata_handler(self, task_type: TaskType) -> list[TaskData]: assert str(task_type).startswith("user:"), "Can only fetch user task data" return self.tasks.get(task_type, []) + def __get_user_all_taskdata_handler(self) -> list[TaskData]: + return [v for k, l in self.tasks.items() if str(k).startswith("user:") for v in l] + def broker_task_decorator( self, task_type: TaskType, diff --git a/silverback/types.py b/silverback/types.py index b61c8b41..e1584386 100644 --- a/silverback/types.py +++ b/silverback/types.py @@ -15,6 +15,7 @@ class TaskType(str, Enum): # System-only Tasks SYSTEM_CONFIG = "system:config" SYSTEM_USER_TASKDATA = "system:user-taskdata" + SYSTEM_USER_ALL_TASKDATA = "system:user-all-taskdata" # User-accessible Tasks STARTUP = "user:startup"