You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/27 13:15:53 UTC

[GitHub] [airflow] ashb commented on issue #12611: Switch from Email to Notification

ashb commented on issue #12611:
URL: https://github.com/apache/airflow/issues/12611#issuecomment-849625657


   In response to someone asking this on the mailing list I proposed this API: https://lists.apache.org/thread.html/rcd7fbd99408f5cdc1cc09e8a1619b629743da158ecf4c9d0eeb411f1%40%3Cdev.airflow.apache.org%3E
   
   ```python
   from airflow.providers.slack.notifiers import send_slack_message
   
   task = MyOperator(
       task_id = "something",
       on_failure_callback= send_slack_message(
           slack_conn_id='slack-default', # Default, not actually required 
   here, for example only
           channels=['#data-ops'],
           mentions=['@ash'],
       ),
   )
   ```
   
   Names can be changed/discussed, this is just a rough idea.
   
   Using this approach means that a) We don't need to add a whole bunch of 
   new config, and b) it can be easily extended/created by providers 
   without needing changes to core -- after all the feature to run code 
   after failure/success already exists, we just want to "package up" the 
   common task of sending a slack message.
   
   I think for consistency of interface too we should deprecate the 
   email_on_failure task attribute too in favour of a similar function.
   
   And finally, perhaps `on_*_callback` gets extended to allow a list of 
   functions instead of just one.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org