Пример #1
0
    def end_of_workflow(self, msg):
        logger.configure(msg, "WORKFLOW")
        on_complete = msg['header'].pop('on_workflow_complete', None)
        if on_complete is not None:
            if not isinstance(on_complete, dict) or not all([key in on_complete for key in ['exchange', 'key']]):
                logger.error("on_workflow_complete should be a dict with keys 'exchange' and 'key'")
            else:
                publish(on_complete['exchange'], on_complete['key'], msg)
                logger.info(f"Publish on_workflow_complete to {on_complete['exchange']} with {on_complete['key']}")

        logger.info("End of workflow")
        job_end(msg["header"].get("jobid"))
Пример #2
0
    def reject(self, msg, job):
        """
        Reject a message because the job is already active within GOB

        :param msg:
        :param job:
        :return:
        """
        # Start a workflow step to reject the message
        msg["header"]["process_id"] = job['id']
        msg["header"]["entity"] = msg["header"].get('collection')
        step = step_start("accept", msg['header'])
        step_status(job['id'], step['id'], STATUS_START)
        # End the workflow step and then the workflow job
        step_status(job['id'], step['id'], STATUS_REJECTED)
        return job_end(job['id'], STATUS_REJECTED)
Пример #3
0
 def test_job_end_missing_id(self):
     job = job_end(None)
     self.assertIsNone(job)
Пример #4
0
 def test_job_end(self):
     job = job_end("any jobid")
     self.assertEqual(job["id"], "any jobid")
     self.assertIsInstance(job["end"], datetime.datetime)
     self.assertEqual(job["status"], "ended")
Пример #5
0
 def end_of_workflow(self, msg):
     logger.configure(msg, "WORKFLOW")
     logger.info(f"End of workflow")
     job_end(msg["header"].get("jobid"))