Tasks Management / Maker-checker logic

Tasks Management / Maker-checker logic

Creating execution action handlers and business event handlers

When user action specified by the task is being passed to backend, the task service sends task_service.resolve_task signal. The approach for handler is to bind to after signal and check the specific executor_action_event of the task. The same approach is used for business event handlers, being required to bind on task_service.complete_task.

# in signals.py in any module def bind_service_signals(): bind_service_signal( 'task_service.resolve_task', handler_hook, bind_type=ServiceSignalBindType.AFTER ) def handler_hook(**kwargs): pass

Creating tasks for BaseService implementations

CheckerLogicServiceMixin allows implementations of core.services.BaseService to generate tasks for create, update and delete actions. this adds create__task methods to the service, with the same API as the methods. Additionally the on_task_complete_service_handler service method allows to generate complete_task handlers for core.services.BaseService implementations.

# In service definition class ExampleService(BaseService, CheckerLogicServiceMixin): ... # to create a task instead of performing create operation, instead of: # ExampleService(user).create(data) ExampleService(user).create_create_task(data) ` #in signals.py (any module, but the same module as service preferred) def bind_service_signals(): bind_service_signal( 'task_service.complete_task', on_task_complete_service_handler(ExampleService), bind_type=ServiceSignalBindType.AFTER )

Did you encounter a problem or do you have a suggestion?

Please contact our Service Desk



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/