Skip to main content

A SWF client library that makes things easy for building workflow logic

Project description

=======================================================
py_swf
=======================================================

.. image:: https://travis-ci.org/Yelp/pyswf.svg?branch=master
:target: https://travis-ci.org/Yelp/pyswf

.. image:: https://coveralls.io/repos/github/Yelp/pyswf/badge.svg?branch=master
:target: https://coveralls.io/github/Yelp/pyswf?branch=master

.. image:: https://readthedocs.org/projects/py-swf/badge/?version=latest
:target: http://py-swf.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/pypi/v/py-swf.svg
:target: https://pypi-hypernode.com/pypi/py-swf/

py_swf is a library that provides a pythonic way to interact with the boto3 SWF client. It provides a thin client above boto3 and tries to provide the same API as boto3's SWF client. This library tries to group the API calls into SWF's framework of deciders, activity runners, and a client that can initiate and terminate workflows. More information on inputs to boto3 can be found in the boto3 :class:`~SWF.Client` class.

The library provides 4 clients:
- A client that allows starting and force-termination of workflows.
- A client that can poll for decision tasks and respond to decision tasks.
- A client that can poll for activity tasks and respond to activity tasks.
- A client that can perform registration of workflows in SWF.

Consumers of this library are expected to write their own daemons that enact business logic.

Example daemon that listens on decision tasks

.. code-block:: python

import boto3
from py_swf.config_definitions import DecisionConfig
from py_swf.clients.decision import DecisionClient

boto_client = boto3.Session(...).client('swf')
decision_config = DecisionConfig(...)

client = DecisionClient(decision_config, boto_client)

while True:
task = client.poll()

... = perform_decision_task(task)

client.finish_decision_with_activity(
task.task_token,
...
)

The heart of the daemon is the :class:`~py_swf.clients.decision.DecisionClient`. You must provide a valid bare boto3 client, and :class:`~py_swf.config_definitions.DecisionConfig` which represents common SWF inputs, such as domain, and some timeouts.

Likewise, you must implement an activity runner:

.. code-block:: python

import boto3
from py_swf.config_definitions import ActivityTaskConfig
from py_swf.clients.activity_task import ActivityTaskClient

boto_client = boto3.Session(...).client('swf')
activity_task_config = ActivityTaskConfig(...)

client = ActivityTaskClient(decision_config, boto_client)

while True:
task = client.poll()

result = perform_activity_task(task.input)

client.finish(
task_token=task.task_token,
result=result,
)

Activity task runners are very similar to deciders. However, they don't have any information of the workflow, and only perform one task given an input and responds with an output.



Documentation
-------------

The full documentation is at http://py-swf.readthedocs.io/en/latest/



History
-------

1.1.0 (2016-10-03)
++++++++++++++++++

* Update botocore version to 1.4.46

1.0.0 (2016-09-09)
++++++++++++++++++

* Initial release of py_swf


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-swf-1.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

py_swf-1.1.0-py2.py3-none-any.whl (12.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file py-swf-1.1.0.tar.gz.

File metadata

  • Download URL: py-swf-1.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py-swf-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cf7bf56adbb13fb50b6b4a3172381deb8f4791e2ce9996977a3017d70eb72730
MD5 0a8617cf246bd5225a245b66f360e156
BLAKE2b-256 c9b3d4019a3c954f9b420072ad020da835d25e075324382f9d61edae509d9f0e

See more details on using hashes here.

File details

Details for the file py_swf-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for py_swf-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8b440fa48ba224019717cfb8de443b4437a11f340a4198f3da2fd540ec9d19b5
MD5 009b1848258f374afbf30d3d4e584e02
BLAKE2b-256 52a4d6d40157ff387fedb8aae345f63bd173ac855d6cc2ee37fc75a349a55abd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page