跳转到主要内容

一个SWF客户端库,使构建工作流逻辑变得简单

项目描述

=======================================================
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: 文档状态

.. image:: https://img.shields.io/pypi/v/py-swf.svg
:target: https://pypi.python.org/pypi/py-swf/

py_swf是一个库,它提供了一种Pythonic的方式来与boto3 SWF客户端交互。它提供了一个在boto3之上的轻量级客户端,并试图提供与boto3的SWF客户端相同的API。该库试图将API调用分组到SWF的决策者、活动运行者和可以启动和终止工作流的客户端的框架中。有关boto3的输入的更多信息,请参阅boto3 :class:`~SWF.Client` 类。

该库提供了4个客户端
- 允许启动和强制终止工作流的客户端。
- 可以轮询决策任务并响应决策任务的客户端。
- 可以轮询活动任务并响应活动任务的客户端。
- 可以在SWF中注册工作流的客户端。

此库的使用者应编写自己的守护程序来实现业务逻辑。

示例守护程序,监听决策任务

.. 代码块 :: python

导入 boto3
从 py_swf.config_definitions 导入 DecisionConfig
从 py_swf.clients.decision 导入 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,
...
)

守护程序的核心是 :class:`~py_swf.clients.decision.DecisionClient`。您必须提供一个有效的裸 boto3 客户端,以及 :class:`~py_swf.config_definitions.DecisionConfig`,它代表常见的 SWF 输入,例如域和一些超时。

同样,您必须实现一个活动运行器

.. 代码块 :: python

导入 boto3
从 py_swf.config_definitions 导入 ActivityTaskConfig
从 py_swf.clients.activity_task 导入 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,
)

活动任务运行器与决策器非常相似,但它们没有任何工作流程信息,并且仅根据输入执行一个任务并返回输出。



文档
-------------

完整文档位于 http://py-swf.readthedocs.io/en/latest/



历史
-------

1.3.0 (2016-12-12)
++++++++++++++++++

* WorkflowClient 现在支持通过过滤器计算打开或关闭的工作流程数量。过滤器包括开始时间、关闭时间、工作流程类型、标签、工作流程 ID 和关闭状态。

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

* 将 botocore 版本更新到 1.4.46

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

* py_swf 的初始发布


项目详情


下载文件

下载适合您平台的应用程序。如果您不确定要选择哪个,请了解有关 安装包 的更多信息。

源分布

py-swf-1.3.0.tar.gz (10.7 kB 查看哈希值)

上传时间

构建分布

py_swf-1.3.0-py2.py3-none-any.whl (14.2 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面