Skip to content

Commit

Permalink
feat: adds task type SYSTEM_USER_ALL_TASKDATA (#83)
Browse files Browse the repository at this point in the history
* feat: adds task type SYSTEM_USER_ALL_TASKDATA

* style: gc
  • Loading branch information
mikeshultz authored May 14, 2024
1 parent f6d02b5 commit 8e89008
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions silverback/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions silverback/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8e89008

Please sign in to comment.