如何使用 PHP 集成 AWS SWF,以便可以从用户界面对其进行管理?
How to integrate AWS SWF using PHP so it can be managed from a user interface?
我正在使用 LAMP 构建一个 CMS,允许管理员将 MP4 上传到 Amazon S3 存储桶,使用 Elastic Transcoder 对其进行多次转换,并更新本地数据库以便使用云锋。
现在每个步骤都按预期工作,一个简单的 SWF 工作流将所有步骤连接起来(只要我从命令行启动启动程序、决策程序和 activity 工作程序,正如我在示例中看到的那样无处不在)。
但是,我正在努力将各个部分与用户界面连接起来:
- 在用户开始上传时使用
pcntl_exec
启动工作流并启动决策程序和 activity 工作人员是正确的方法吗?还有其他选择吗?
- activity 工作人员和决策者完成每项任务的执行,因此必须再次启动它们以进行下一个决策或 activity,工作流启动器是否负责每次启动工作人员或我我错过了什么?
- 假设
1.
和 2.
的方向正确,在 UI 中实施反馈应该很简单,使用 AJAX 调用来检查记录的状态在数据库中,这将在每个步骤中更新。否则,有更好的方法吗?
编辑:有人可能会发现这对第 2 点有用:
Program the activity worker to poll for another activity task after it has completed the task at hand. This creates a loop where the activity worker continuously polls for and completes tasks.
Until the decider schedules activity tasks, though, these polls time out with no tasks and your workers just continue polling.
If no decision task is available, Amazon SWF holds the connection open for up to 60 seconds, and returns a task as soon as it becomes available. If no task becomes available, Amazon SWF returns an empty response [...] Make sure to program your decider to poll for another task if it receives an empty response.
我会建议 运行 activity 和决策者工作人员永久独立于 Web 服务器进程。您可以将它们作为守护进程启动。他们应该循环轮询新任务并根据您的逻辑处理它们。因此任务执行完成后无需再次启动它们。
工作流实例从网络服务器进程启动,因为启动它们是一个相对快速的调用,不会等待工作流执行完成。
在 UI 中实施反馈通常是通过网络服务器代码轮询特殊 activity 类型(如 "UIFeedback")来完成的。当工作流需要通知 UI 某事时,它会安排此 activity 发送到网络服务器,网络服务器将 activity 输入数据转发到 AJAX 代码。
我正在使用 LAMP 构建一个 CMS,允许管理员将 MP4 上传到 Amazon S3 存储桶,使用 Elastic Transcoder 对其进行多次转换,并更新本地数据库以便使用云锋。
现在每个步骤都按预期工作,一个简单的 SWF 工作流将所有步骤连接起来(只要我从命令行启动启动程序、决策程序和 activity 工作程序,正如我在示例中看到的那样无处不在)。
但是,我正在努力将各个部分与用户界面连接起来:
- 在用户开始上传时使用
pcntl_exec
启动工作流并启动决策程序和 activity 工作人员是正确的方法吗?还有其他选择吗? - activity 工作人员和决策者完成每项任务的执行,因此必须再次启动它们以进行下一个决策或 activity,工作流启动器是否负责每次启动工作人员或我我错过了什么?
- 假设
1.
和2.
的方向正确,在 UI 中实施反馈应该很简单,使用 AJAX 调用来检查记录的状态在数据库中,这将在每个步骤中更新。否则,有更好的方法吗?
编辑:有人可能会发现这对第 2 点有用:
Program the activity worker to poll for another activity task after it has completed the task at hand. This creates a loop where the activity worker continuously polls for and completes tasks.
Until the decider schedules activity tasks, though, these polls time out with no tasks and your workers just continue polling.
If no decision task is available, Amazon SWF holds the connection open for up to 60 seconds, and returns a task as soon as it becomes available. If no task becomes available, Amazon SWF returns an empty response [...] Make sure to program your decider to poll for another task if it receives an empty response.
我会建议 运行 activity 和决策者工作人员永久独立于 Web 服务器进程。您可以将它们作为守护进程启动。他们应该循环轮询新任务并根据您的逻辑处理它们。因此任务执行完成后无需再次启动它们。
工作流实例从网络服务器进程启动,因为启动它们是一个相对快速的调用,不会等待工作流执行完成。
在 UI 中实施反馈通常是通过网络服务器代码轮询特殊 activity 类型(如 "UIFeedback")来完成的。当工作流需要通知 UI 某事时,它会安排此 activity 发送到网络服务器,网络服务器将 activity 输入数据转发到 AJAX 代码。