-
Notifications
You must be signed in to change notification settings - Fork 8
/
gearman.rb
71 lines (64 loc) · 1.54 KB
/
gearman.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env ruby
#
# = Name
# Gearman
#
# == Description
# This file provides a Ruby interface for communicating with the Gearman
# distributed job system.
#
# "Gearman is a system to farm out work to other machines, dispatching
# function calls to machines that are better suited to do work, to do work
# in parallel, to load balance lots of function calls, or to call functions
# between languages." -- http://www.danga.com/gearman/
#
# == Version
# 0.0.1
#
# == Author
# Daniel Erat <dan-ruby@erat.org>
#
# == License
# FIXME
# = Gearman
#
# == Usage
# require 'gearman'
#
# # Create a new client and tell it about two job servers.
# c = Gearman::Client.new
# c.job_servers = ['127.0.0.1:7003', '127.0.0.1:7004']
#
# # Create two tasks, using an "add" function to sum two numbers.
# t1 = Gearman::Task.new('add', '5 + 2')
# t2 = Gearman::Task.new('add', '1 + 3')
#
# # Make the tasks print the data they get back from the server.
# t1.on_complete {|d| puts "t1 got #{d}" }
# t2.on_complete {|d| puts "t2 got #{d}" }
#
# # Create a taskset, add the two tasks to it, and wait until they finish.
# ts = Gearman::TaskSet.new(c)
# ts.add_task(t1)
# ts.add_task(t2)
# ts.wait
#
# Or, a more simple example:
#
# c = Gearman::Client.new('127.0.0.1')
# puts c.do_task('add', '2 + 2')
#
module Gearman
DEFAULT_PORT = 7003
require 'gearman/client'
require 'gearman/task'
require 'gearman/taskset'
require 'gearman/util'
require 'gearman/worker'
class InvalidArgsError < Exception
end
class ProtocolError < Exception
end
class NetworkError < Exception
end
end