Пример #1
0
    def emit_triggers(self):
        triggers = self.triggers_to_emit()
        if not triggers:
            return

        log.info(f"{self} publishing triggers: [{', '.join(triggers)}]")
        job_id = '.'.join(self.job_run_id.split('.')[:-1])
        for trigger in triggers:
            EventBus.publish(f"{job_id}.{self.action_name}.{trigger}")
Пример #2
0
    def emit_triggers(self):
        triggers = self.triggers_to_emit()
        if not triggers:
            return

        log.info(f"{self} publishing triggers: [{', '.join(triggers)}]")
        job_id = '.'.join(self.job_run_id.split('.')[:-1])
        for trigger in triggers:
            EventBus.publish(f"{job_id}.{self.action_name}.{trigger}")
Пример #3
0
    def emit_triggers(self):
        if isinstance(self.trigger_downstreams, bool):
            shortdate = self.render_template("{shortdate}")
            triggers = [f"shortdate.{shortdate}"]
        elif isinstance(self.trigger_downstreams, dict):
            triggers = [
                f"{k}.{self.render_template(v)}"
                for k, v in self.trigger_downstreams.items()
            ]
        else:
            log.error(f"{self} trigger_downstreams must be true or dict")
            return

        log.info(f"{self} publishing triggers: [{', '.join(triggers)}]")
        job_id = '.'.join(self.job_run_id.split('.')[:-1])
        for trigger in triggers:
            EventBus.publish(f"{job_id}.{self.action_name}.{trigger}")
Пример #4
0
    def publish(self, event):
        if not EventBus.instance:
            return dict(error='EventBus disabled')

        if EventBus.has_event(event):
            msg = f"event {event} already published"
            log.warning(msg)
            return dict(response=msg)

        if not EventBus.publish(event):
            msg = f'could not publish {event}'
            log.error(msg)
            return dict(error=msg)

        return dict(response='OK')
Пример #5
0
    def publish(self, event):
        if not EventBus.instance:
            return dict(error='EventBus disabled')

        if EventBus.has_event(event):
            msg = f"event {event} already published"
            log.warning(msg)
            return dict(response=msg)

        if not EventBus.publish(event):
            msg = f'could not publish {event}'
            log.error(msg)
            return dict(error=msg)

        return dict(response='OK')