我正在尝试使用Simple Workflow服务来管理rails应用程序的作业。我的工作基于文档中的预订示例。 rake任务看起来像:
require "#{Rails.root}/app/helpers/application_helper"
include ApplicationHelper
namespace :swf do
desc 'Start activity worker'
task :activity => :environment do
swf, domain = swf_domain
activity_worker = AWS::Flow::ActivityWorker.new(swf.client, domain, SWF_ACTIVITY_TASK_LIST, ScrapeActivity) { {:use_forking => false} }
activity_worker.start
end
desc 'Start workflow worker'
task :workflow => :environment do
swf, domain = swf_domain
worker = AWS::Flow::WorkflowWorker.new(swf.client, domain, SWF_WORKFLOW_TASK_LIST, ScrapeWorkflow)
worker.start
end
desc 'Queue activities'
task :scrape => :environment do
swf, domain = swf_domain
my_workflow_client = workflow_client(swf.client, domain) { {:from_class => "ScrapeWorkflow"} }
Product.all.each do |product|
$workflow_execution = my_workflow_client.start_execution(product.asin)
end
end
end
其余代码为online。我正在使用aws-flow gem(我添加了aws-flow-core),但是当我尝试运行activity worker时,我收到一个错误:uninitialized constant AWS::Flow::ActivityWorker
。
答案 0 :(得分:0)
我通过添加到rake任务修复了这个问题:
require "#{ENV['GEM_HOME']}/gems/aws-flow-1.0.0/lib/aws/decider.rb"