ayl-beanstalk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88e80db809fd24274ca8a7ac03f2abb7e7ae8527
4
+ data.tar.gz: ff8f5cc4c9c5aeb2547f56c2aae430435ea6cc69
5
+ SHA512:
6
+ metadata.gz: 3dc71dbcf479f955a30ab21606321c6131a7abaacf624015328576f98b2e54b1c5bd8fd9a6bd47dce0a7957c88e500a8b0bc3cdc0b0e760c7100ab89f60423ab
7
+ data.tar.gz: ae83500715d9fe73bb63f4b4651ff4ed925c2c6a56c965651f59a75e8727c7dc6ab6da7f4811a0578f2633ca43ce57db79aab3c452b156abb0fb5ccdcd79227c
data/Gemfile CHANGED
@@ -2,21 +2,19 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
- gem 'ayl', ">= 0.3.0"
6
- gem 'beanstalk-client', ">= 1.1.0"
7
- gem 'daemons', ">= 1.1.0"
5
+ gem 'ayl', "~> 0.4"
6
+ gem 'beaneater', '~> 1.0'
7
+ gem 'daemons', "~> 1.1"
8
8
 
9
9
  # Add dependencies to develop your gem here.
10
10
  # Include everything needed to run rake, tests, features, etc.
11
11
  group :development do
12
- gem "rspec", ">= 2.3.0"
13
- gem "bundler", ">= 1.0.0"
14
- gem "jeweler", ">= 1.6.4"
15
- gem "rcov", ">= 0"
16
- gem 'pry'
12
+ gem "rspec", "~> 2.14"
13
+ gem "bundler", "~> 1.10"
14
+ gem "jeweler", "~> 2.0"
17
15
  end
18
16
 
19
- group :test do
20
- gem 'rails', ">= 3.0.0"
21
- gem 'pry'
22
- end
17
+ group :test, :development do
18
+ gem 'rails', "~> 4.1"
19
+ gem 'pry', "~> 0.9"
20
+ end
data/Gemfile.lock CHANGED
@@ -1,125 +1,146 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.1.2)
5
- actionpack (= 3.1.2)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.2)
8
- activemodel (= 3.1.2)
9
- activesupport (= 3.1.2)
10
- builder (~> 3.0.0)
4
+ actionmailer (4.1.10)
5
+ actionpack (= 4.1.10)
6
+ actionview (= 4.1.10)
7
+ mail (~> 2.5, >= 2.5.4)
8
+ actionpack (4.1.10)
9
+ actionview (= 4.1.10)
10
+ activesupport (= 4.1.10)
11
+ rack (~> 1.5.2)
12
+ rack-test (~> 0.6.2)
13
+ actionview (4.1.10)
14
+ activesupport (= 4.1.10)
15
+ builder (~> 3.1)
11
16
  erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.5)
14
- rack-cache (~> 1.1)
15
- rack-mount (~> 0.8.2)
16
- rack-test (~> 0.6.1)
17
- sprockets (~> 2.1.0)
18
- activemodel (3.1.2)
19
- activesupport (= 3.1.2)
20
- builder (~> 3.0.0)
21
- i18n (~> 0.6)
22
- activerecord (3.1.2)
23
- activemodel (= 3.1.2)
24
- activesupport (= 3.1.2)
25
- arel (~> 2.2.1)
26
- tzinfo (~> 0.3.29)
27
- activeresource (3.1.2)
28
- activemodel (= 3.1.2)
29
- activesupport (= 3.1.2)
30
- activesupport (3.1.2)
31
- multi_json (~> 1.0)
32
- arel (2.2.1)
33
- ayl (0.3.0)
34
- beanstalk-client (1.1.1)
35
- builder (3.0.0)
17
+ activemodel (4.1.10)
18
+ activesupport (= 4.1.10)
19
+ builder (~> 3.1)
20
+ activerecord (4.1.10)
21
+ activemodel (= 4.1.10)
22
+ activesupport (= 4.1.10)
23
+ arel (~> 5.0.0)
24
+ activesupport (4.1.10)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
28
+ thread_safe (~> 0.1)
29
+ tzinfo (~> 1.1)
30
+ addressable (2.3.8)
31
+ arel (5.0.1.20140414130214)
32
+ ayl (0.4.0)
33
+ beaneater (1.0.0)
34
+ builder (3.2.2)
36
35
  coderay (0.9.8)
37
36
  daemons (1.1.4)
38
- diff-lcs (1.1.3)
37
+ descendants_tracker (0.0.4)
38
+ thread_safe (~> 0.3, >= 0.3.1)
39
+ diff-lcs (1.2.5)
39
40
  erubis (2.7.0)
40
- git (1.2.5)
41
- hike (1.2.1)
42
- i18n (0.6.0)
43
- jeweler (1.6.4)
44
- bundler (~> 1.0)
41
+ faraday (0.9.1)
42
+ multipart-post (>= 1.2, < 3)
43
+ git (1.2.9.1)
44
+ github_api (0.12.3)
45
+ addressable (~> 2.3)
46
+ descendants_tracker (~> 0.0.4)
47
+ faraday (~> 0.8, < 0.10)
48
+ hashie (>= 3.3)
49
+ multi_json (>= 1.7.5, < 2.0)
50
+ nokogiri (~> 1.6.3)
51
+ oauth2
52
+ hashie (3.4.2)
53
+ highline (1.7.2)
54
+ i18n (0.7.0)
55
+ jeweler (2.0.1)
56
+ builder
57
+ bundler (>= 1.0)
45
58
  git (>= 1.2.5)
59
+ github_api
60
+ highline (>= 1.6.15)
61
+ nokogiri (>= 1.5.10)
46
62
  rake
47
- json (1.6.1)
48
- mail (2.3.0)
49
- i18n (>= 0.4.0)
50
- mime-types (~> 1.16)
51
- treetop (~> 1.4.8)
63
+ rdoc
64
+ json (1.8.3)
65
+ jwt (1.5.0)
66
+ mail (2.6.3)
67
+ mime-types (>= 1.16, < 3)
52
68
  method_source (0.6.7)
53
69
  ruby_parser (>= 2.3.1)
54
- mime-types (1.17.2)
55
- multi_json (1.0.3)
56
- polyglot (0.3.3)
70
+ mime-types (2.6.1)
71
+ mini_portile (0.6.2)
72
+ minitest (5.7.0)
73
+ multi_json (1.11.0)
74
+ multi_xml (0.5.5)
75
+ multipart-post (2.0.0)
76
+ nokogiri (1.6.6.2)
77
+ mini_portile (~> 0.6.0)
78
+ oauth2 (1.0.0)
79
+ faraday (>= 0.8, < 0.10)
80
+ jwt (~> 1.0)
81
+ multi_json (~> 1.3)
82
+ multi_xml (~> 0.5)
83
+ rack (~> 1.2)
57
84
  pry (0.9.7.4)
58
85
  coderay (~> 0.9.8)
59
86
  method_source (~> 0.6.7)
60
87
  ruby_parser (>= 2.3.1)
61
88
  slop (~> 2.1.0)
62
- rack (1.3.5)
63
- rack-cache (1.1)
64
- rack (>= 0.4)
65
- rack-mount (0.8.3)
66
- rack (>= 1.0.0)
67
- rack-ssl (1.3.2)
68
- rack
69
- rack-test (0.6.1)
89
+ rack (1.5.3)
90
+ rack-test (0.6.3)
70
91
  rack (>= 1.0)
71
- rails (3.1.2)
72
- actionmailer (= 3.1.2)
73
- actionpack (= 3.1.2)
74
- activerecord (= 3.1.2)
75
- activeresource (= 3.1.2)
76
- activesupport (= 3.1.2)
77
- bundler (~> 1.0)
78
- railties (= 3.1.2)
79
- railties (3.1.2)
80
- actionpack (= 3.1.2)
81
- activesupport (= 3.1.2)
82
- rack-ssl (~> 1.3.2)
92
+ rails (4.1.10)
93
+ actionmailer (= 4.1.10)
94
+ actionpack (= 4.1.10)
95
+ actionview (= 4.1.10)
96
+ activemodel (= 4.1.10)
97
+ activerecord (= 4.1.10)
98
+ activesupport (= 4.1.10)
99
+ bundler (>= 1.3.0, < 2.0)
100
+ railties (= 4.1.10)
101
+ sprockets-rails (~> 2.0)
102
+ railties (4.1.10)
103
+ actionpack (= 4.1.10)
104
+ activesupport (= 4.1.10)
83
105
  rake (>= 0.8.7)
84
- rdoc (~> 3.4)
85
- thor (~> 0.14.6)
86
- rake (0.9.2.2)
87
- rcov (0.9.11)
88
- rdoc (3.11)
89
- json (~> 1.4)
90
- rspec (2.7.0)
91
- rspec-core (~> 2.7.0)
92
- rspec-expectations (~> 2.7.0)
93
- rspec-mocks (~> 2.7.0)
94
- rspec-core (2.7.1)
95
- rspec-expectations (2.7.0)
96
- diff-lcs (~> 1.1.2)
97
- rspec-mocks (2.7.0)
106
+ thor (>= 0.18.1, < 2.0)
107
+ rake (10.4.2)
108
+ rdoc (4.2.0)
109
+ rspec (2.99.0)
110
+ rspec-core (~> 2.99.0)
111
+ rspec-expectations (~> 2.99.0)
112
+ rspec-mocks (~> 2.99.0)
113
+ rspec-core (2.99.2)
114
+ rspec-expectations (2.99.2)
115
+ diff-lcs (>= 1.1.3, < 2.0)
116
+ rspec-mocks (2.99.3)
98
117
  ruby_parser (2.3.1)
99
118
  sexp_processor (~> 3.0)
100
119
  sexp_processor (3.0.8)
101
120
  slop (2.1.0)
102
- sprockets (2.1.1)
103
- hike (~> 1.2)
121
+ sprockets (3.2.0)
104
122
  rack (~> 1.0)
105
- tilt (~> 1.1, != 1.3.0)
106
- thor (0.14.6)
107
- tilt (1.3.3)
108
- treetop (1.4.10)
109
- polyglot
110
- polyglot (>= 0.3.1)
111
- tzinfo (0.3.31)
123
+ sprockets-rails (2.3.1)
124
+ actionpack (>= 3.0)
125
+ activesupport (>= 3.0)
126
+ sprockets (>= 2.8, < 4.0)
127
+ thor (0.19.1)
128
+ thread_safe (0.3.5)
129
+ tzinfo (1.2.2)
130
+ thread_safe (~> 0.1)
112
131
 
113
132
  PLATFORMS
114
133
  ruby
115
134
 
116
135
  DEPENDENCIES
117
- ayl (>= 0.3.0)
118
- beanstalk-client (>= 1.1.0)
119
- bundler (>= 1.0.0)
120
- daemons (>= 1.1.0)
121
- jeweler (>= 1.6.4)
122
- pry
123
- rails (>= 3.0.0)
124
- rcov
125
- rspec (>= 2.3.0)
136
+ ayl (~> 0.4)
137
+ beaneater (~> 1.0)
138
+ bundler (~> 1.10)
139
+ daemons (~> 1.1)
140
+ jeweler (~> 2.0)
141
+ pry (~> 0.9)
142
+ rails (~> 4.1)
143
+ rspec (~> 2.14)
144
+
145
+ BUNDLED WITH
146
+ 1.10.3
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 j0hnds@gmail.com
1
+ Copyright (c) 2011-2015 j0hnds@gmail.com
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -3,8 +3,8 @@
3
3
  This gem provides a reference implementation of a beanstalk Engine for the
4
4
  {ayl}[https://github.com/j0hnds/ayl] gem.
5
5
 
6
- If you want to use this technology in a Rails 3.* application you can do the
7
- following in your config/environments/*.rb files:
6
+ If you want to use this technology in a Rails 4.* application you can do the
7
+ following in your config/application.rb or config/environments/*.rb files:
8
8
 
9
9
  YourApp::Application.configure do
10
10
 
@@ -31,6 +31,29 @@ following in your config/environments/*.rb files:
31
31
  # The default is 'default'.
32
32
  # Ayl::MessageOptions.default_queue_name = '1.2.3'
33
33
 
34
+ # Set the default failed job handler to 'decay'. The default is
35
+ # 'delete', another option is to 'bury'. So, 'delete' will delete
36
+ # a failed job. 'bury' will move the job to the 'buried' state
37
+ # requiring a 'kick' to place it back in the ready state. 'decay'
38
+ # means that if the job has been reserved less than 'failed_job_count'
39
+ # (see below), it will be placed back on the tube with a delay of
40
+ # 'failed_job_delay' (see below). This allows jobs to be retried
41
+ # with a delay. This is handy for the case where the jobs may be
42
+ # dependent on a third party that can have spotty availability
43
+ # (like anything on the internet).
44
+ Ayl::MessageOptions.default_failed_job_handler = 'decay'
45
+
46
+ # Set the default failed job count to '3'. That is the default.
47
+ # If the failed job handler is 'decay', this means it retry the
48
+ # job until it has been reserved three times (initial try, then
49
+ # two failures).
50
+ Ayl::MessageOptions.default_failed_job_count = 4
51
+
52
+ # Set the default failed job delay to '30'. That is the default.
53
+ # If the failed job handler is 'decay', this means that there
54
+ # will be a 30 second delay between each retry of the job.
55
+ Ayl::MessageOptions.default_failed_job_delay = 10
56
+
34
57
  # Set up the logger for Ayl
35
58
  Ayl::Logger.instance.logger = ::Rails.logger
36
59
 
@@ -77,6 +100,6 @@ The ayl_worker_control script can easily be invoked by an /etc/init.d script to
77
100
 
78
101
  == Copyright
79
102
 
80
- Copyright (c) 2011 j0hnds@gmail.com. See LICENSE.txt for
103
+ Copyright (c) 2011-2015 j0hnds@gmail.com. See LICENSE.txt for
81
104
  further details.
82
105
 
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.homepage = "http://github.com/j0hnds/ayl-beanstalk"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Ayl extension to provide beanstalk support.}
21
- gem.description = %Q{Ayl extension to provide beanstalk support.}
21
+ gem.description = %Q{Ayl extension to provide beanstalk support for applications requiring async processing.}
22
22
  gem.email = "j0hnds@gmail.com"
23
23
  gem.authors = ["j0hnds@gmail.com"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -2,15 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: ayl-beanstalk 0.4.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "ayl-beanstalk"
8
- s.version = "0.3.0"
9
+ s.version = "0.4.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["j0hnds@gmail.com"]
12
- s.date = "2013-08-07"
13
- s.description = "Ayl extension to provide beanstalk support."
14
+ s.date = "2015-06-15"
15
+ s.description = "Ayl extension to provide beanstalk support for applications requiring async processing."
14
16
  s.email = "j0hnds@gmail.com"
15
17
  s.executables = ["ayl_beanstalk", "ayl_worker", "ayl_worker_control"]
16
18
  s.extra_rdoc_files = [
@@ -49,41 +51,40 @@ Gem::Specification.new do |s|
49
51
  ]
50
52
  s.homepage = "http://github.com/j0hnds/ayl-beanstalk"
51
53
  s.licenses = ["MIT"]
52
- s.require_paths = ["lib"]
53
- s.rubygems_version = "1.8.23"
54
+ s.rubygems_version = "2.4.6"
54
55
  s.summary = "Ayl extension to provide beanstalk support."
55
56
 
56
57
  if s.respond_to? :specification_version then
57
- s.specification_version = 3
58
+ s.specification_version = 4
58
59
 
59
60
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<ayl>, [">= 0.3.0"])
61
- s.add_runtime_dependency(%q<beanstalk-client>, [">= 1.1.0"])
62
- s.add_runtime_dependency(%q<daemons>, [">= 1.1.0"])
63
- s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
64
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
65
- s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
66
- s.add_development_dependency(%q<rcov>, [">= 0"])
67
- s.add_development_dependency(%q<pry>, [">= 0"])
61
+ s.add_runtime_dependency(%q<ayl>, ["~> 0.4"])
62
+ s.add_runtime_dependency(%q<beaneater>, ["~> 1.0"])
63
+ s.add_runtime_dependency(%q<daemons>, ["~> 1.1"])
64
+ s.add_development_dependency(%q<rspec>, ["~> 2.14"])
65
+ s.add_development_dependency(%q<bundler>, ["~> 1.10"])
66
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
67
+ s.add_development_dependency(%q<rails>, ["~> 4.1"])
68
+ s.add_development_dependency(%q<pry>, ["~> 0.9"])
68
69
  else
69
- s.add_dependency(%q<ayl>, [">= 0.3.0"])
70
- s.add_dependency(%q<beanstalk-client>, [">= 1.1.0"])
71
- s.add_dependency(%q<daemons>, [">= 1.1.0"])
72
- s.add_dependency(%q<rspec>, [">= 2.3.0"])
73
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
74
- s.add_dependency(%q<jeweler>, [">= 1.6.4"])
75
- s.add_dependency(%q<rcov>, [">= 0"])
76
- s.add_dependency(%q<pry>, [">= 0"])
70
+ s.add_dependency(%q<ayl>, ["~> 0.4"])
71
+ s.add_dependency(%q<beaneater>, ["~> 1.0"])
72
+ s.add_dependency(%q<daemons>, ["~> 1.1"])
73
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.10"])
75
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
76
+ s.add_dependency(%q<rails>, ["~> 4.1"])
77
+ s.add_dependency(%q<pry>, ["~> 0.9"])
77
78
  end
78
79
  else
79
- s.add_dependency(%q<ayl>, [">= 0.3.0"])
80
- s.add_dependency(%q<beanstalk-client>, [">= 1.1.0"])
81
- s.add_dependency(%q<daemons>, [">= 1.1.0"])
82
- s.add_dependency(%q<rspec>, [">= 2.3.0"])
83
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
84
- s.add_dependency(%q<jeweler>, [">= 1.6.4"])
85
- s.add_dependency(%q<rcov>, [">= 0"])
86
- s.add_dependency(%q<pry>, [">= 0"])
80
+ s.add_dependency(%q<ayl>, ["~> 0.4"])
81
+ s.add_dependency(%q<beaneater>, ["~> 1.0"])
82
+ s.add_dependency(%q<daemons>, ["~> 1.1"])
83
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
84
+ s.add_dependency(%q<bundler>, ["~> 1.10"])
85
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
86
+ s.add_dependency(%q<rails>, ["~> 4.1"])
87
+ s.add_dependency(%q<pry>, ["~> 0.9"])
87
88
  end
88
89
  end
89
90
 
data/bin/ayl_beanstalk CHANGED
@@ -4,8 +4,9 @@
4
4
  # running this script, enter 'beastalk_info.rb --help' on the command line.
5
5
  #
6
6
  require 'date'
7
+ require 'json'
7
8
  require 'optparse'
8
- require 'beanstalk-client'
9
+ require 'beaneater'
9
10
 
10
11
  DEFAULT_COMMAND = 'statistics'
11
12
 
@@ -37,7 +38,12 @@ class BeanstalkCommander
37
38
  #
38
39
  def job_statistics(job_number)
39
40
  raise "Must specify a job number to get the statistics for" unless job_number
40
- format_statistics(pool.open_connections.first.job_stats(job_number))
41
+ job = pool.jobs.find(job_number)
42
+ if job.nil?
43
+ puts "Unable to find job with id: #{job_number}"
44
+ else
45
+ format_statistics(job.stats)
46
+ end
41
47
  end
42
48
 
43
49
  #
@@ -45,7 +51,12 @@ class BeanstalkCommander
45
51
  #
46
52
  def tube_statistics(*args)
47
53
  puts "Statistics for Tube: #{@tube}"
48
- format_statistics(pool.stats_tube(@tube))
54
+ tube = pool.tubes[@tube]
55
+ if tube.nil?
56
+ puts "Unable to find tube: #{@tube}"
57
+ else
58
+ format_statistics(tube.stats)
59
+ end
49
60
  end
50
61
 
51
62
  #
@@ -61,12 +72,8 @@ class BeanstalkCommander
61
72
  # Lists the tubes active on beanstalk
62
73
  #
63
74
  def list_tubes(*args)
64
- tubes = pool.list_tubes
65
- puts "Tubes in use"
66
- puts "------------"
67
- tubes.each_pair do | host, tubes |
68
- puts host
69
- tubes.each { | tube | puts " - #{tube}" }
75
+ pool.tubes.all.each do | tube |
76
+ puts " - #{tube.name}"
70
77
  end
71
78
  end
72
79
 
@@ -76,7 +83,7 @@ class BeanstalkCommander
76
83
  #
77
84
  def peek_job(job_number)
78
85
  raise "Must specify a job number to peek" unless job_number
79
- job = pool.peek_job(job_number)
86
+ job = pool.jobs.find(job_number)
80
87
  format_job(job)
81
88
  end
82
89
 
@@ -85,42 +92,63 @@ class BeanstalkCommander
85
92
  #
86
93
  def delete(job_number)
87
94
  raise "Must specify a job number to delete" unless job_number
88
- pool.open_connections.first.delete(job_number)
95
+ job = pool.jobs.find(job_number)
96
+ if job.nil?
97
+ puts "Unable to find job with ID: #{job_number}"
98
+ else
99
+ job.delete
100
+ end
89
101
  end
90
102
 
91
103
  #
92
104
  # Displays the most current job on the ready queue
93
105
  #
94
106
  def peek_ready(*args)
95
- pool.use(@tube)
96
- job = pool.peek_ready
97
- format_job(job)
107
+ tube = pool.tubes[@tube]
108
+ if tube.nil?
109
+ puts "No tube: #{@tube}"
110
+ else
111
+ job = tube.peek(:ready)
112
+ format_job(job)
113
+ end
98
114
  end
99
115
 
100
116
  #
101
117
  # Kick any buried/delayed jobs in te queue
102
118
  #
103
119
  def kick(*args)
104
- pool.use(@tube)
105
- pool.open_connections.first.kick 1
120
+ tube = pool.tubes[@tube]
121
+ if tube.nil?
122
+ puts "No tube: #{@tube}"
123
+ else
124
+ tube.kick
125
+ end
106
126
  end
107
127
 
108
128
  #
109
129
  # Displays the most current job on the delayed queue
110
130
  #
111
131
  def peek_delayed(*args)
112
- pool.use(@tube)
113
- job = pool.peek_delayed
114
- format_job(job)
132
+ tube = pool.tubes[@tube]
133
+ if tube.nil?
134
+ puts "No tube: #{@tube}"
135
+ else
136
+ job = tube.peek(:delayed)
137
+ format_job(job)
138
+ end
115
139
  end
116
140
 
117
141
  #
118
142
  # Displays the most current job on the buried queue
119
143
  #
120
144
  def peek_buried(*args)
121
- pool.use(@tube)
122
- job = pool.peek_buried
123
- format_job(job)
145
+ tube = pool.tubes[@tube]
146
+ if tube.nil?
147
+ puts "No tube: #{@tube}"
148
+ else
149
+ job = tube.peek(:buried)
150
+ format_job(job)
151
+ end
124
152
  end
125
153
 
126
154
  #
@@ -128,10 +156,14 @@ class BeanstalkCommander
128
156
  #
129
157
  def put_job(job_body)
130
158
  raise "Must specify a job body to put" unless job_body
131
- puts "Putting (#{job_body}) on tube: #{@tube}"
132
- pool.use(@tube)
133
- pool.put(job_body)
134
- puts "Job was put"
159
+ tube = pool.tubes[@tube]
160
+ if tube.nil?
161
+ puts "No tube: #{@tube}"
162
+ else
163
+ puts "Putting (#{job_body}) on tube: #{@tube}"
164
+ tube.put(job_body)
165
+ puts "Job was put"
166
+ end
135
167
  end
136
168
 
137
169
  def kill_worker
@@ -141,15 +173,23 @@ class BeanstalkCommander
141
173
  def put_ayl_job(job_body)
142
174
  raise "Must specify a job body to put" unless job_body
143
175
  puts "Putting (#{job_body}) on tube: #{@tube}"
144
- pool.use(@tube)
145
- pool.put({:type => :ayl, :code => job_body}.to_yaml)
146
- puts "Job was put"
176
+ tube = pool.tubes[@tube]
177
+ if tube.nil?
178
+ puts "No tube: #{@tube}"
179
+ else
180
+ tube.put({:type => :ayl, :code => job_body}.to_json)
181
+ puts "Job was put"
182
+ end
147
183
  end
148
184
 
149
185
  def put_sleep_job(*args)
150
186
  puts "Putting job on tube '#{@tube}' that will sleep for 20 seconds."
151
- pool.use(@tube)
152
- pool.put(SLEEP_COMMAND.to_yaml)
187
+ tube = pool.tubes[@tube]
188
+ if tube.nil?
189
+ puts "No tube: #{@tube}"
190
+ else
191
+ tube.put(SLEEP_COMMAND.to_json)
192
+ end
153
193
  end
154
194
 
155
195
  #
@@ -158,22 +198,31 @@ class BeanstalkCommander
158
198
  #
159
199
  def eat_job(*args)
160
200
  # Reserve the next job on the queue
161
- pool.watch(@tube)
162
- job = pool.reserve(10)
163
- raise "No job to reserve" unless job
164
- puts "Reserved job"
165
- format_job(job)
166
- job.delete
167
- puts "Deleted job"
201
+ tube = pool.tubes[@tube]
202
+ if tube.nil?
203
+ puts "No tube: #{@tube}"
204
+ else
205
+ job = tube.peek(:ready)
206
+ if job.nil?
207
+ puts "No job to eat"
208
+ else
209
+ format_job(job)
210
+ job.delete
211
+ puts "Deleted job"
212
+ end
213
+ end
168
214
  end
169
215
 
170
- def eat_all_jobs
171
- pool.watch(@tube)
172
- while (!(job = pool.reserve(0)).nil?)
173
- puts "Reserved job"
174
- format_job(job)
175
- job.delete
176
- puts "Deleted job"
216
+ def eat_all_jobs(state='ready')
217
+ tube = pool.tubes[@tube]
218
+ if tube.nil?
219
+ puts "No tube: #{@tube}"
220
+ else
221
+ while (!(job = tube.peek(state.to_sym)).nil?)
222
+ format_job(job)
223
+ job.delete
224
+ puts "Deleted job"
225
+ end
177
226
  end
178
227
  end
179
228
 
@@ -187,12 +236,16 @@ class BeanstalkCommander
187
236
  # It is fast and awesome.
188
237
  #
189
238
  def move_jobs(to_tube)
190
- pool.watch(@tube)
191
- pool.use(to_tube)
239
+ ttube = pool.tubes[to_tube]
240
+ if ttube.nil?
241
+ puts "No To Tube: #{to_tube}"
242
+ return
243
+ end
244
+ pool.tubes.watch!(@tube)
192
245
  while true
193
- job = pool.reserve(0)
246
+ job = pool.tubes.reserve(0)
194
247
  if job
195
- pool.put(job.body)
248
+ ttube.put(job.body)
196
249
  job.delete
197
250
  else
198
251
  break
@@ -206,7 +259,7 @@ class BeanstalkCommander
206
259
  # Returns the connected beanstalk pool
207
260
  #
208
261
  def pool
209
- @pool ||= Beanstalk::Pool.new(["#{@host}:#{@port}"])
262
+ @pool ||= Beaneater.new("#{@host}:#{@port}")
210
263
  end
211
264
 
212
265
  #