Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
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'
Exemple #5
0
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'
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
    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)
Exemple #11
0
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):
Exemple #12
0
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')))
Exemple #13
0
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(
Exemple #14
0
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')))