Sha256: 2f115b3f9d95e17711f40485979ec04246509b8812ec55d8297b8dba5b69ba0d
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module JFlow module Activity class Worker attr_reader :domain, :tasklist def initialize(domain, tasklist) @domain = domain @tasklist = tasklist end def start! loop do log "Polling for task on #{domain} - #{tasklist}" poll end end private def poll response = JFlow.configuration.swf_client.poll_for_activity_task(poll_params) if response.task_token process_task(response) else log "Got no task" end end def process_task(response) log "Got task #{response.task_token}" task = JFlow::Activity::Task.new(response) begin task.run! rescue => exception task.failed!(exception) end end def identity @identity ||= "#{`hostname`.chomp}-#{Thread.current.object_id}" end def log(str) JFlow.configuration.logger.info "[#{Thread.current.object_id}] #{str}" end def poll_params { domain: domain, task_list: { name: tasklist, }, identity: identity, } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jflow-0.2.5 | lib/jflow/activity/worker.rb |