Skip to content

Commit

Permalink
doc: add a new guide for the hooks (#173)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Crocfer <nicolas.crocfer@ovhcloud.com>
  • Loading branch information
ncrocfer committed Dec 8, 2022
1 parent bccd812 commit 8f17b18
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/docs/guides/trigger-hooks.md
Original file line number Diff line number Diff line change
@@ -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)
Binary file added docs/docs/img/hooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8f17b18

Please sign in to comment.