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.
First you must download and install the beanstalkd server.
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
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.
There’s a google group called beanstalk-talk for all discussion regarding beanstalkd and the various client libraries.
How to submit patches
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/.
You can share this code under the terms of the GPL version 3.
Comments are welcome. Send any questions or comments to the beanstalk-talk google group.