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.
Files changed (54) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +6 -4
  4. data/README.md +111 -0
  5. data/examples/client.rb +1 -2
  6. data/examples/client_reverse_nohost.rb +30 -0
  7. data/examples/{client_reverse.rb → client_reverse_wait.rb} +9 -11
  8. data/examples/worker.rb +8 -5
  9. data/examples/worker_reverse_string.rb +12 -17
  10. data/gearman-ruby.gemspec +3 -5
  11. data/lib/gearman.rb +17 -77
  12. data/lib/gearman/client.rb +129 -147
  13. data/lib/gearman/connection.rb +158 -0
  14. data/lib/gearman/connection_pool.rb +131 -0
  15. data/lib/gearman/exceptions.rb +24 -0
  16. data/lib/gearman/logging.rb +19 -0
  17. data/lib/gearman/packet.rb +61 -0
  18. data/lib/gearman/task.rb +1 -1
  19. data/lib/gearman/task_set.rb +67 -0
  20. data/lib/gearman/version.rb +1 -1
  21. data/lib/gearman/worker.rb +185 -412
  22. data/lib/gearman/worker/ability.rb +55 -0
  23. data/lib/gearman/worker/callbacks.rb +39 -0
  24. data/lib/gearman/worker/job.rb +44 -0
  25. data/spec/client_spec.rb +32 -20
  26. data/spec/connection_pool_spec.rb +55 -0
  27. data/spec/spec_helper.rb +5 -0
  28. data/spec/task_spec.rb +10 -0
  29. data/spec/taskset_spec.rb +2 -2
  30. metadata +18 -37
  31. data/HOWTO +0 -146
  32. data/README +0 -9
  33. data/TODO +0 -8
  34. data/VERSION.yml +0 -4
  35. data/examples/calculus_client.rb +0 -39
  36. data/examples/calculus_worker.rb +0 -45
  37. data/examples/client.php +0 -23
  38. data/examples/client_background.rb +0 -14
  39. data/examples/client_data.rb +0 -16
  40. data/examples/client_epoch.rb +0 -23
  41. data/examples/client_exception.rb +0 -19
  42. data/examples/client_prefix.rb +0 -17
  43. data/examples/gearman_environment.sh +0 -25
  44. data/examples/scale_image.rb +0 -31
  45. data/examples/scale_image_worker.rb +0 -34
  46. data/examples/server.rb +0 -15
  47. data/examples/worker_data.rb +0 -16
  48. data/examples/worker_exception.rb +0 -14
  49. data/examples/worker_prefix.rb +0 -25
  50. data/examples/worker_reverse_to_file.rb +0 -18
  51. data/examples/worker_signals.rb +0 -36
  52. data/lib/gearman/taskset.rb +0 -293
  53. data/lib/gearman/util.rb +0 -211
  54. data/spec/util_spec.rb +0 -67
@@ -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