def run(self): connection = get_connection() workflows = [w for module in self.args.modules for w in module] if self.args.register_workflows: log.info("Registering workflow types") for workflow in workflows: created = register_workflow(connection=connection, domain=self.args.domain, workflow=workflow) if created: log.info("Workflow type %s(%s): registered.", workflow.name, workflow.version) else: log.info("Workflow type %s(%s): already registered.", workflow.name, workflow.version) log.info("Start decider worker...") worker = Worker(connection=connection, domain=self.args.domain, task_list=self.args.task_list, workflows=workflows) while True: try: worker.run() except Exception: # Doesn't catch KeyboardInterrupt log.exception("Decider crashed!")
def test_get_connection(self): swf_connection = get_connection() # Boto3 client object are dynamically forged... self.assertEqual(swf_connection.__class__.__name__, "SWF") self.assertEqual(swf_connection.__class__.__module__, "botocore.client") self.assertEqual(swf_connection.meta.config.read_timeout, 70) self.assertEqual(swf_connection.meta.config.region_name, "us-east-1") self.assertEqual(swf_connection.meta.service_model.service_name, "swf")
def run_swf_command(command_name, **kwargs): connection = kwargs.get('connection') if connection is None: connection = get_connection() command = getattr(connection, command_name) callargs = {k: v for k, v in kwargs.items() if v is not None} try: response = command(**callargs) except ClientError as err: sys.exit(err) else: metadata = response.pop('ResponseMetadata', {}) success = metadata.get('HTTPStatusCode') == 200 if success: return response else: sys.exit('Error: %s' % response)
def setUp(self): self.mock_swf = mock_swf() self.mock_swf.start() self.connection = get_connection() self.connection.register_domain(name="TEST", workflowExecutionRetentionPeriodInDays="1")
def valid_workflow_registration(workflow): connection = get_connection() with mock_swf(): connection.register_domain(name='TEST', workflowExecutionRetentionPeriodInDays='1') register_workflow(connection, 'TEST', workflow)