Skip to content
Official! Ruby library for the Gearman distributed job system
Branch: master
Clone or download
Latest commit 7abd3e4 Apr 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Dedupe client / worker example Dec 2, 2014
lib v bump Jun 6, 2016
spec fix test Jun 1, 2016
test Adding connection failovers, spec tests and some code cleanup. Jul 28, 2013
.gitignore Adding connection failovers, spec tests and some code cleanup. Jul 28, 2013
.travis.yml Add travis rubygems integration Jun 9, 2016
.yourbase.yml Fix build yaml Apr 26, 2019
CHANGELOG.md Updated change log, version bump, clean up client option requests Feb 12, 2015
Gemfile
LICENSE Added examples for our testing and added Copyright to XING AG. Jun 23, 2009
README.md Updated README Dec 1, 2014
Rakefile Adding connection failovers, spec tests and some code cleanup. Jul 28, 2013
gearman-ruby.gemspec Bumped version and changed source code homepage Nov 29, 2014

README.md

gearman-ruby

Travis CI Build Status

What is this?

This is a pure-Ruby library for the gearman distributed job system.

What needs to be done?

More testing, some code cleanup.

What's in this?

Right now, this library has both client and worker support for Ruby apps.

Getting Started

Client

A very simple client that submits a "sleep" job and waits for 100 seconds for results:

require 'rubygems'
require 'gearman'

servers = ['localhost:4730', 'localhost:4731']

client = Gearman::Client.new(servers)
taskset = Gearman::TaskSet.new(client)

task = Gearman::Task.new('sleep', 20)
task.on_complete {|d| puts d }

taskset.add_task(task)
taskset.wait(100)

Worker

A worker that will process jobs in the 'sleep' queue:

require 'rubygems'
require 'logger'
require 'gearman'

servers = ['localhost:4730']

w = Gearman::Worker.new(servers)
logger = Logger.new(STDOUT)

# Add a handler for a "sleep" function that takes a single argument, the
# number of seconds to sleep before reporting success.
w.add_ability("sleep") do |data,job|
 seconds = 10
 logger.info "Sleeping for #{seconds} seconds"
 (1..seconds.to_i).each do |i|
   sleep 1
   # Report our progress to the job server every second.
   job.report_status(i, seconds)
 end
 # Report success.
 true
end

loop { w.work }

Authors

Contributors (past and present)

  • Kim Altintop
  • Josh Black (raskchanky)
  • Colin Curtin (perplexes)
  • Brian Cobb (bcobb)
  • Pablo A. Delgado (pablete)
  • Daniel Erat
  • Antonio Garrote
  • Stefan Kaes (skaes)
  • Ladislav Martincik
  • Mauro Pompilio (malditogeek)
  • Lee Reilly (leereilly)
  • Clint Shryock (catsby)
  • Andy Triggs (andyt)

License

Released under the MIT license, originally developed by XING AG. See the LICENSE file for further details.

You can’t perform that action at this time.