Beanstalk Client

Get Version

1.0.2

→ ‘beanstalk-client’

What

This is a Ruby client library for the Beanstalk protocol.

beanstalkd is a fast, distributed, in-memory work-queue service. Its interface is generic, but is intended for use in reducing the latency of page views in high-volume web applications by running most time-consuming tasks asynchronously.

Installing

First you must download and install the beanstalkd server.

Then just:

sudo gem install beanstalk-client

and you’re ready to go!

How to use it

Here’s an example of the low-level Ruby interface.

First, have one process put a job into the queue:

beanstalk = Beanstalk::Pool.new(['localhost:11300'])
...
beanstalk.put('hello')

Then start another process to take jobs out of the queue and run them:

beanstalk = Beanstalk::Pool.new(['localhost:11300'])
loop do
  job = beanstalk.reserve
  puts job.body # prints "hello"
  job.delete
end

Rails Integration

But you very likely want to use this in a Rails project. In that case, you should check out the Async Observer Rails plugin. It gives far more functionality and a super-easy-to-use interface.

Forum

There’s a google group called beanstalk-talk for all discussion regarding beanstalkd and the various client libraries.

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The repository is http://xph.us/src/beanstalk-client-ruby.git for anonymous access.

You can browse the repo at http://xph.us/git/beanstalk-client-ruby/.

License

You can share this code under the terms of the GPL version 3.

Contact

Comments are welcome. Send any questions or comments to the beanstalk-talk google group.

Keith Rarick, 27th May 2008
Theme extended from Paul Battley