Thursday, May 19, 2011

Cloudist: Simple, scalable job queue for Ruby powered by AMQP and Event Machine

Wynn sat down with Nick Quaranto at Red Dirt Ruby Conference to talk about Gemcutter, RubyGems.org, and how to get started creating your own Ruby gem.

Rubyists seeking to move processing to the background have long relied on projects like Delayed Job and Resque. Now, Ivan Vanderbyl offers another option. Cloudist is powered by AMQP and EventMachine and aims to provide a simple yet highly scalable job queue for Ruby apps.

Cloudist workers can be in the form of a block:

Cloudist.start { log.info("Started Worker") job('make.sandwich') { log.info("JOB (#{id}) Make sandwich with #{data[:bread]} bread") job.started! (1..20).each do |i| job.progress(i * 5) sleep(1) raise ArgumentError, "NOT GOOD!" if i == 4 end job.finished! }}

… or a Ruby class:

class SandwichWorker < Cloudist::Worker def process log.info("Processing queue: #{queue.name}") log.info(data.inspect) job.started! (1..5).each do |i| job.progress(i * 20) # sleep(1) # raise ArgumentError, "NOT GOOD!" if i == 4 end job.finished! endendCloudist.signal_trap!Cloudist.start(:heartbeat => 10, :logging => false) { Cloudist.handle('make.sandwich').with(SandwichWorker)}

For usage, configuration, and more examples, check out the project repo on GitHub.

[Source on GitHub]

No comments:

Post a Comment