-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: add a new guide for the hooks (#173)
Signed-off-by: Nicolas Crocfer <nicolas.crocfer@ovhcloud.com>
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters