Send task and workflow notifications out of the transaction

Change-Id: I5c0781a0e54e718e1b7e708150b06487d9297cc7
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
This commit is contained in:
Oleg Ovcharuk 2019-05-31 12:28:00 +03:00
parent e25da33607
commit a75b07ec5f
2 changed files with 18 additions and 14 deletions

View File

@ -76,13 +76,15 @@ class Task(object):
notifier = notif.get_notifier(cfg.CONF.notifier.type)
event = events.identify_task_event(old_task_state, new_task_state)
notifier.notify(
self.task_ex.id,
self.task_ex.to_dict(),
event,
self.task_ex.updated_at,
publishers
)
def _send_notification():
notifier.notify(
self.task_ex.id,
self.task_ex.to_dict(),
event,
self.task_ex.updated_at,
publishers
)
post_tx_queue.register_operation(_send_notification)
def is_completed(self):
return self.task_ex and states.is_completed(self.task_ex.state)

View File

@ -74,13 +74,15 @@ class Workflow(object):
notifier = notif.get_notifier(cfg.CONF.notifier.type)
notifier.notify(
self.wf_ex.id,
self.wf_ex.to_dict(),
event,
self.wf_ex.updated_at,
publishers
)
def _send_notification():
notifier.notify(
self.wf_ex.id,
self.wf_ex.to_dict(),
event,
self.wf_ex.updated_at,
publishers
)
post_tx_queue.register_operation(_send_notification)
@profiler.trace('workflow-start')
def start(self, wf_def, wf_ex_id, input_dict, desc='', params=None):