def __init__(self): """Initialize flow object.""" self.name = config.FEED_NAME self.version = '2.0' self.domain = 'dev_uvarov' self.timeout = 60 * 3 self.create = activity.create( self.domain, self.name, version=self.version, on_exception=self.on_exception)
def __init__(self, domain, name): """Create the workflow. Args: domain (str): the domain to attach this workflow to. name (str): the name of the workflow. """ self.name = name self.domain = domain self.create_activity = activity.create(domain, name)
def test_create_activity(monkeypatch): """Test the creation of an activity via `create`. """ monkeypatch.setattr(activity.Activity, '__init__', lambda self: None) create = activity.create('domain_name', 'flow_name') current_activity = create(name='activity_name') assert isinstance(current_activity, activity.Activity) assert current_activity.name == 'flow_name_activity_name' assert current_activity.task_list == 'flow_name_activity_name' assert current_activity.domain == 'domain_name'
def test_create_activity(monkeypatch, boto_client): """Test the creation of an activity via `create`. """ create = activity.create(boto_client, 'domain_name', 'flow_name') current_activity = create(name='activity_name') assert isinstance(current_activity, activity.Activity) assert current_activity.name == 'flow_name_activity_name' assert current_activity.task_list == 'flow_name_activity_name' assert current_activity.domain == 'domain_name' assert current_activity.client == boto_client
def test_create_external_activity(monkeypatch, boto_client): """Test the creation of an external activity via `create`. """ create = activity.create(boto_client, 'domain_name', 'flow_name') current_activity = create(name='activity_name', timeout=60, heartbeat=40, external=True) assert isinstance(current_activity, activity.ExternalActivity) assert current_activity.name == 'flow_name_activity_name' assert current_activity.task_list == 'flow_name_activity_name' assert current_activity.domain == 'domain_name' assert isinstance(current_activity.runner, runner.External) assert current_activity.runner.heartbeat() == 40 assert current_activity.runner.timeout() == 60
def test_create_external_activity(monkeypatch): """Test the creation of an external activity via `create`. """ monkeypatch.setattr(activity.Activity, '__init__', lambda self: None) create = activity.create('domain_name', 'flow_name') current_activity = create(name='activity_name', timeout=60, heartbeat=40, external=True) assert isinstance(current_activity, activity.ExternalActivity) assert current_activity.name == 'flow_name_activity_name' assert current_activity.task_list == 'flow_name_activity_name' assert current_activity.domain == 'domain_name' assert isinstance(current_activity.runner, runner.External) assert current_activity.runner.heartbeat() == 40 assert current_activity.runner.timeout() == 60
def test_create_external_activity(monkeypatch): """Test the creation of an external activity via `create`. """ monkeypatch.setattr(activity.Activity, '__init__', lambda self: None) create = activity.create('domain_name', 'flow_name') current_activity = create( name='activity_name', timeout=60, heartbeat=40, external=True) assert isinstance(current_activity, activity.ExternalActivity) assert current_activity.name == 'flow_name_activity_name' assert current_activity.task_list == 'flow_name_activity_name' assert current_activity.domain == 'domain_name' assert isinstance(current_activity.runner, runner.External) assert current_activity.runner.heartbeat() == 40 assert current_activity.runner.timeout() == 60
def __init__(self, domain, version): """Create a WorkFlow flow. Args: domain (str): domain workflow runs under. version (str): version of the workflow (ex 1.0). """ if not os.environ.get(HELLO_WORLD_USER): print('Please set your {} environment variable'.format( HELLO_WORLD_USER)) sys.exit(1) # Name of the SWF WorkFlow self.name = 'HelloWorld{}'.format(os.environ.get(HELLO_WORLD_USER)) self.domain = domain self.version = version self.create = activity.create(self.domain, self.name, version=self.version, on_exception=self.on_exception)
from __future__ import print_function from garcon import activity from garcon import runner domain = 'dev' name = 'workflow_name' create = activity.create(domain, name) activity_1 = create( name='activity_1', tasks=runner.Sync(lambda activity, context: print('activity_1'))) activity_2 = create(name='activity_2', requires=[activity_1], tasks=runner.Async( lambda activity, context: print('activity_2_task_1'), lambda activity, context: print('activity_2_task_2'))) activity_3 = create( name='activity_3', requires=[activity_1], tasks=runner.Sync(lambda activity, context: print('activity_3'))) activity_4 = create( name='activity_4', requires=[activity_3, activity_2], tasks=runner.Sync(lambda activity, context: print('activity_4'))) def on_exception(actor, exception):
from __future__ import print_function from garcon import activity from garcon import runner domain = 'dev' name = 'workflow_name' create = activity.create(domain, name) activity_1 = create( name='activity_1', tasks=runner.Sync( lambda activity, context: print('activity_1'))) activity_2 = create( name='activity_2', requires=[activity_1], tasks=runner.Async( lambda activity, context: print('activity_2_task_1'), lambda activity, context: print('activity_2_task_2'))) activity_3 = create( name='activity_3', requires=[activity_1], tasks=runner.Sync( lambda activity, context: print('activity_3')))
import boto.swf.layer2 as swf from garcon import activity from garcon import task domain = 'dev' create = activity.create(domain) activity_1 = create( name='activity_1', tasks=task.SyncTasks( lambda: print('activity_1'))) activity_2 = create( name='activity_2', requires=[activity_1], tasks=task.AsyncTasks( lambda: print('activity_2_task_1'), lambda: print('activity_2_task_2'))) activity_3 = create( name='activity_3', requires=[activity_1], tasks=task.SyncTasks( lambda: print('activity_3'))) activity_4 = create( name='activity_4', requires=[activity_3, activity_2], tasks=task.SyncTasks(
from garcon import activity from garcon import runner import boto3 client = boto3.client('swf', region_name='us-east-1') domain = 'dev' name = 'workflow_name' create = activity.create(client, domain, name) activity_1 = create( name='activity_1', tasks=runner.Sync(lambda activity, context: print('activity_1'))) activity_2 = create(name='activity_2', requires=[activity_1], tasks=runner.Async( lambda activity, context: print('activity_2_task_1'), lambda activity, context: print('activity_2_task_2'))) activity_3 = create( name='activity_3', requires=[activity_1], tasks=runner.Sync(lambda activity, context: print('activity_3'))) activity_4 = create( name='activity_4', requires=[activity_3, activity_2], tasks=runner.Sync(lambda activity, context: print('activity_4')))