diff --git a/docs/docs/guides/trigger-hooks.md b/docs/docs/guides/trigger-hooks.md new file mode 100644 index 0000000..1bd7ba8 --- /dev/null +++ b/docs/docs/guides/trigger-hooks.md @@ -0,0 +1,33 @@ +# Trigger Hooks + +Director allows you to define a success and an error tasks in your workflows definitions. These tasks are called **hooks**, and they will be executed at the end of your workflows depending on their result. + +You can define them in the `workflows.yml` file using the `hooks` key: + +```yaml +example.ETL: + tasks: + - EXTRACT + - TRANSFORM + - LOAD + hooks: + failure: ERROR_HANDLER + success: SUCCESS_HANDLER +``` + +These hooks are normal Celery tasks: + +```python +@task(name="ERROR_HANDLER") +def error_handler(*args, **kwargs): + print("I'm executed because the workflow failed") + + +@task(name="SUCCESS_HANDLER") +def success_handler(*args, **kwargs): + print("I'm executed because the workflow succeeded") +``` + +Depending on the result of your workflows the corresponding hook will be called: + +![Hooks](../img/hooks.png) \ No newline at end of file diff --git a/docs/docs/img/hooks.png b/docs/docs/img/hooks.png new file mode 100644 index 0000000..a6ef6f0 Binary files /dev/null and b/docs/docs/img/hooks.png differ diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 1cd8b12..ea8a89b 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -23,6 +23,7 @@ nav: - 'Error Tracking': 'guides/error-tracking.md' - 'Custom Configuration': 'guides/custom-configuration.md' - 'Use Flower': 'guides/use-flower.md' + - 'Trigger Hooks': 'guides/trigger-hooks.md' - API: 'api.md' extra_css: