gearman-ruby 3.0.8 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -0
- data/CHANGELOG.md +6 -4
- data/README.md +111 -0
- data/examples/client.rb +1 -2
- data/examples/client_reverse_nohost.rb +30 -0
- data/examples/{client_reverse.rb → client_reverse_wait.rb} +9 -11
- data/examples/worker.rb +8 -5
- data/examples/worker_reverse_string.rb +12 -17
- data/gearman-ruby.gemspec +3 -5
- data/lib/gearman.rb +17 -77
- data/lib/gearman/client.rb +129 -147
- data/lib/gearman/connection.rb +158 -0
- data/lib/gearman/connection_pool.rb +131 -0
- data/lib/gearman/exceptions.rb +24 -0
- data/lib/gearman/logging.rb +19 -0
- data/lib/gearman/packet.rb +61 -0
- data/lib/gearman/task.rb +1 -1
- data/lib/gearman/task_set.rb +67 -0
- data/lib/gearman/version.rb +1 -1
- data/lib/gearman/worker.rb +185 -412
- data/lib/gearman/worker/ability.rb +55 -0
- data/lib/gearman/worker/callbacks.rb +39 -0
- data/lib/gearman/worker/job.rb +44 -0
- data/spec/client_spec.rb +32 -20
- data/spec/connection_pool_spec.rb +55 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/task_spec.rb +10 -0
- data/spec/taskset_spec.rb +2 -2
- metadata +18 -37
- data/HOWTO +0 -146
- data/README +0 -9
- data/TODO +0 -8
- data/VERSION.yml +0 -4
- data/examples/calculus_client.rb +0 -39
- data/examples/calculus_worker.rb +0 -45
- data/examples/client.php +0 -23
- data/examples/client_background.rb +0 -14
- data/examples/client_data.rb +0 -16
- data/examples/client_epoch.rb +0 -23
- data/examples/client_exception.rb +0 -19
- data/examples/client_prefix.rb +0 -17
- data/examples/gearman_environment.sh +0 -25
- data/examples/scale_image.rb +0 -31
- data/examples/scale_image_worker.rb +0 -34
- data/examples/server.rb +0 -15
- data/examples/worker_data.rb +0 -16
- data/examples/worker_exception.rb +0 -14
- data/examples/worker_prefix.rb +0 -25
- data/examples/worker_reverse_to_file.rb +0 -18
- data/examples/worker_signals.rb +0 -36
- data/lib/gearman/taskset.rb +0 -293
- data/lib/gearman/util.rb +0 -211
- data/spec/util_spec.rb +0 -67
data/spec/util_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'socket'
|
3
|
-
require 'rspec'
|
4
|
-
require 'rspec/mocks'
|
5
|
-
require 'gearman'
|
6
|
-
|
7
|
-
describe Gearman::Util do
|
8
|
-
before(:each) do
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should generate a task from two arguments" do
|
13
|
-
task = Gearman::Util.get_task_from_args("queue", "data")
|
14
|
-
task.should_not be nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should generate a task from three arguments" do
|
18
|
-
task = Gearman::Util.get_task_from_args("queue", "data", {:background => true})
|
19
|
-
task.should_not be nil
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should raise an exception with more than three arguments" do
|
23
|
-
expect {
|
24
|
-
Gearman::Util.get_task_from_args("one", "two", {:three => :four}, :five)
|
25
|
-
}.to raise_error
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should raise a NetworkError when it didn't write as much as expected to a socket" do
|
29
|
-
socket = double(TCPSocket)
|
30
|
-
socket.should_receive(:write).with(anything).and_return(0)
|
31
|
-
|
32
|
-
task = Gearman::Task.new("job_queue", "data")
|
33
|
-
request = task.get_submit_packet
|
34
|
-
expect {
|
35
|
-
Gearman::Util.send_request(socket, request)
|
36
|
-
}.to raise_error
|
37
|
-
end
|
38
|
-
|
39
|
-
context "normalizing job servers" do
|
40
|
-
it "should handle a string for input" do
|
41
|
-
Gearman::Util.normalize_job_servers("localhost:1234").should eq ["localhost:1234"]
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should handle an array of host:port without changing a thing" do
|
45
|
-
servers = ["localhost:123", "localhost:456"]
|
46
|
-
Gearman::Util.normalize_job_servers(servers).should eq servers
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should append the default port to anything in the array that doesn't have a port" do
|
50
|
-
in_servers = ["foo.bar.com:123", "narf.quiddle.com"]
|
51
|
-
out_servers = ["foo.bar.com:123", "narf.quiddle.com:4730"]
|
52
|
-
Gearman::Util.normalize_job_servers(in_servers).should eq out_servers
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should convert a host:port & handle into its corresponding string" do
|
57
|
-
Gearman::Util.handle_to_str("localhost:4730", "foo:1").should eq "localhost:4730//foo:1"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should convert a host:port & handle string into its components" do
|
61
|
-
Gearman::Util.str_to_handle("localhost:4730//foo:1").should eq ["localhost:4730", "foo:1"]
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should convert an ability name with prefix into its correct format" do
|
65
|
-
Gearman::Util.ability_name_with_prefix("test", "a").should eq "test\ta"
|
66
|
-
end
|
67
|
-
end
|