Sha256: eb3a96f65a2b6f0d94a883b8d29b853ebb60fdf854048fd19afbc70e7f95ebcc
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
# Cloudst Example: Sandwich Worker # # This example demonstrates receiving a job and sending back events to the client to let it know we've started and finsihed # making a sandwich. From here you could dispatch an eat.sandwich event. # # Be sure to update the Cloudist connection settings if they differ from defaults: # user: guest # pass: guest # port: 5672 # host: localhost # vhost: / # $:.unshift File.dirname(__FILE__) + '/../lib' require "rubygems" require "cloudist" class SandwichWorker < Cloudist::Worker def process log.info("Processing #{queue.name} job: #{id}") # This will trigger the start event # Appending ! to the end of a method will trigger an # event reply with its name # # e.g. job.working! # job.started! (1..5).each do |i| # This sends a progress reply, you could use this to # update a progress bar in your UI # # usage: #progress([INTEGER 0 - 100]) job.progress(i * 20) # Work hard! sleep(1) # Uncomment this to test error handling in Listener # raise ArgumentError, "NOT GOOD!" if i == 4 end # Trigger finished event job.finished! end end Cloudist.signal_trap! Cloudist.start(:logging => false, :worker_prefetch => 2) { Cloudist.handle('make.sandwich').with(SandwichWorker) }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cloudist-0.5.0 | examples/sandwich_worker_with_class.rb |
cloudist-0.4.4 | examples/sandwich_worker_with_class.rb |
cloudist-0.4.3 | examples/sandwich_worker_with_class.rb |