beaneater 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +37 -19
- data/examples/demo.rb +1 -2
- data/lib/beaneater.rb +56 -3
- data/lib/beaneater/configuration.rb +3 -1
- data/lib/beaneater/connection.rb +123 -26
- data/lib/beaneater/errors.rb +1 -1
- data/lib/beaneater/job/collection.rb +57 -36
- data/lib/beaneater/job/record.rb +27 -27
- data/lib/beaneater/stats.rb +28 -5
- data/lib/beaneater/stats/fast_struct.rb +1 -1
- data/lib/beaneater/stats/stat_struct.rb +8 -2
- data/lib/beaneater/tube/collection.rb +67 -26
- data/lib/beaneater/tube/record.rb +38 -24
- data/lib/beaneater/version.rb +3 -3
- data/test/beaneater_test.rb +1 -7
- data/test/connection_test.rb +37 -1
- data/test/job_test.rb +3 -7
- data/test/jobs_test.rb +12 -40
- data/test/prompt_regexp_test.rb +4 -3
- data/test/stat_struct_test.rb +10 -0
- data/test/stats_test.rb +7 -7
- data/test/test_helper.rb +30 -6
- data/test/tube_test.rb +9 -20
- data/test/tubes_test.rb +59 -54
- metadata +2 -8
- data/lib/beaneater/pool.rb +0 -166
- data/lib/beaneater/pool_command.rb +0 -79
- data/test/pool_command_test.rb +0 -90
- data/test/pool_test.rb +0 -185
data/test/tube_test.rb
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../test_helper', __FILE__)
|
|
4
4
|
|
5
5
|
describe Beaneater::Tube do
|
6
6
|
before do
|
7
|
-
@
|
8
|
-
@tube = Beaneater::Tube.new(@
|
7
|
+
@beanstalk = Beaneater.new('localhost')
|
8
|
+
@tube = Beaneater::Tube.new(@beanstalk, 'baz')
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "for #put" do
|
@@ -26,22 +26,15 @@ describe Beaneater::Tube do
|
|
26
26
|
assert_equal "delayed put #{@time}", @tube.peek(:delayed).body
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should
|
30
|
-
Beaneater
|
31
|
-
|
32
|
-
|
33
|
-
assert_equal 'foo', @tube.put("bar put #{@time}")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should try to put 3 times before to raise" do
|
37
|
-
Beaneater::Connection.any_instance.expects(:transmit).once.with(includes('use baz'), {})
|
38
|
-
Beaneater::Connection.any_instance.expects(:transmit).with(includes("bar put #{@time}"), {}).
|
39
|
-
times(3).raises(Beaneater::DrainingError.new(nil, nil))
|
40
|
-
assert_raises(Beaneater::DrainingError) { @tube.put "bar put #{@time}" }
|
29
|
+
it "should support custom serializer" do
|
30
|
+
Beaneater.configure.job_serializer = lambda { |b| JSON.dump(b) }
|
31
|
+
@tube.put({ foo: "bar"})
|
32
|
+
assert_equal '{"foo":"bar"}', @tube.peek(:ready).body
|
41
33
|
end
|
42
34
|
|
43
35
|
after do
|
44
36
|
Beaneater::Connection.any_instance.unstub(:transmit)
|
37
|
+
Beaneater.configure.job_serializer = lambda { |b| b }
|
45
38
|
end
|
46
39
|
end # put
|
47
40
|
|
@@ -140,7 +133,7 @@ describe Beaneater::Tube do
|
|
140
133
|
describe "for #pause" do
|
141
134
|
before do
|
142
135
|
@time = Time.now.to_i
|
143
|
-
@tube = Beaneater::Tube.new(@
|
136
|
+
@tube = Beaneater::Tube.new(@beanstalk, 'bam')
|
144
137
|
@tube.put "foo pause #{@time}"
|
145
138
|
end
|
146
139
|
|
@@ -164,7 +157,7 @@ describe Beaneater::Tube do
|
|
164
157
|
end
|
165
158
|
|
166
159
|
it "should raise error for empty tube" do
|
167
|
-
assert_raises(Beaneater::NotFoundError) { @
|
160
|
+
assert_raises(Beaneater::NotFoundError) { @beanstalk.tubes.find('fake_tube').stats }
|
168
161
|
end
|
169
162
|
end # stats
|
170
163
|
|
@@ -202,8 +195,4 @@ describe Beaneater::Tube do
|
|
202
195
|
assert_equal [0, 0, 0], tube_counts.call
|
203
196
|
end
|
204
197
|
end # clear
|
205
|
-
|
206
|
-
after do
|
207
|
-
cleanup_tubes!(['baz'])
|
208
|
-
end
|
209
198
|
end # Beaneater::Tube
|
data/test/tubes_test.rb
CHANGED
@@ -5,8 +5,8 @@ require File.expand_path('../test_helper', __FILE__)
|
|
5
5
|
describe Beaneater::Tubes do
|
6
6
|
describe "for #find" do
|
7
7
|
before do
|
8
|
-
@
|
9
|
-
@tubes = Beaneater::Tubes.new(@
|
8
|
+
@beanstalk = stub
|
9
|
+
@tubes = Beaneater::Tubes.new(@beanstalk)
|
10
10
|
end
|
11
11
|
|
12
12
|
it("should return Tube obj") { assert_kind_of Beaneater::Tube, @tubes.find(:foo) }
|
@@ -16,143 +16,148 @@ describe Beaneater::Tubes do
|
|
16
16
|
|
17
17
|
describe "for #use" do
|
18
18
|
before do
|
19
|
-
@
|
19
|
+
@beanstalk = Beaneater.new('localhost')
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should switch to used tube for valid name" do
|
23
|
-
tube = Beaneater::Tube.new(@
|
24
|
-
@
|
25
|
-
assert_equal 'some_name', @
|
23
|
+
tube = Beaneater::Tube.new(@beanstalk, 'some_name')
|
24
|
+
@beanstalk.tubes.use('some_name')
|
25
|
+
assert_equal 'some_name', @beanstalk.tubes.used.name
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should raise for invalid tube name" do
|
29
|
-
assert_raises(Beaneater::InvalidTubeName) { @
|
29
|
+
assert_raises(Beaneater::InvalidTubeName) { @beanstalk.tubes.use('; ') }
|
30
30
|
end
|
31
31
|
end # use
|
32
32
|
|
33
33
|
describe "for #watch & #watched" do
|
34
34
|
before do
|
35
|
-
@
|
35
|
+
@beanstalk = Beaneater.new('localhost')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should watch specified tubes' do
|
39
|
-
@
|
40
|
-
@
|
41
|
-
assert_equal ['default', 'foo', 'bar'].sort, @
|
39
|
+
@beanstalk.tubes.watch('foo')
|
40
|
+
@beanstalk.tubes.watch('bar')
|
41
|
+
assert_equal ['default', 'foo', 'bar'].sort, @beanstalk.tubes.watched.map(&:name).sort
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should raise invalid name for bad tube' do
|
45
|
-
assert_raises(Beaneater::InvalidTubeName) { @
|
45
|
+
assert_raises(Beaneater::InvalidTubeName) { @beanstalk.tubes.watch('; ') }
|
46
46
|
end
|
47
47
|
end # watch! & watched
|
48
48
|
|
49
49
|
describe "for #all" do
|
50
50
|
before do
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
51
|
+
@beanstalk = Beaneater.new('localhost')
|
52
|
+
@beanstalk.tubes.find('foo').put 'bar'
|
53
|
+
@beanstalk.tubes.find('bar').put 'foo'
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should retrieve all tubes' do
|
57
57
|
['default', 'foo', 'bar'].each do |t|
|
58
|
-
assert @
|
58
|
+
assert @beanstalk.tubes.all.map(&:name).include?(t)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end # all
|
62
62
|
|
63
|
+
describe "for Enumerable" do
|
64
|
+
before do
|
65
|
+
@beanstalk = Beaneater.new('localhost')
|
66
|
+
@beanstalk.tubes.find('foo').put 'bar'
|
67
|
+
@beanstalk.tubes.find('bar').put 'foo'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should map tubes' do
|
71
|
+
['default', 'foo', 'bar'].each do |t|
|
72
|
+
assert @beanstalk.tubes.map(&:name).include?(t)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
63
77
|
describe "for #used" do
|
64
78
|
before do
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@
|
79
|
+
@beanstalk = Beaneater.new('localhost')
|
80
|
+
@beanstalk.tubes.find('foo').put 'bar'
|
81
|
+
@beanstalk.tubes.find('bar').put 'foo'
|
68
82
|
end
|
69
83
|
|
70
84
|
it 'should retrieve used tube' do
|
71
|
-
assert_equal 'bar', @
|
85
|
+
assert_equal 'bar', @beanstalk.tubes.used.name
|
72
86
|
end
|
73
87
|
|
74
88
|
it 'should support dashed tubes' do
|
75
|
-
@
|
76
|
-
assert_equal 'der-bam', @
|
89
|
+
@beanstalk.tubes.find('der-bam').put 'foo'
|
90
|
+
assert_equal 'der-bam', @beanstalk.tubes.used.name
|
77
91
|
end
|
78
92
|
end # used
|
79
93
|
|
80
94
|
describe "for #watch!" do
|
81
95
|
before do
|
82
|
-
@
|
96
|
+
@beanstalk = Beaneater.new('localhost')
|
83
97
|
end
|
84
98
|
|
85
99
|
it 'should watch specified tubes' do
|
86
|
-
@
|
87
|
-
@
|
88
|
-
assert_equal ['bar'].sort, @
|
100
|
+
@beanstalk.tubes.watch!(:foo)
|
101
|
+
@beanstalk.tubes.watch!('bar')
|
102
|
+
assert_equal ['bar'].sort, @beanstalk.tubes.watched.map(&:name).sort
|
89
103
|
end
|
90
104
|
end # watch!
|
91
105
|
|
92
106
|
describe "for #ignore" do
|
93
107
|
before do
|
94
|
-
@
|
108
|
+
@beanstalk = Beaneater.new('localhost')
|
95
109
|
end
|
96
110
|
|
97
111
|
it 'should ignore specified tubes' do
|
98
|
-
@
|
99
|
-
@
|
100
|
-
@
|
101
|
-
assert_equal ['default', 'bar'].sort, @
|
112
|
+
@beanstalk.tubes.watch('foo')
|
113
|
+
@beanstalk.tubes.watch('bar')
|
114
|
+
@beanstalk.tubes.ignore('foo')
|
115
|
+
assert_equal ['default', 'bar'].sort, @beanstalk.tubes.watched.map(&:name).sort
|
102
116
|
end
|
103
117
|
end # ignore
|
104
118
|
|
105
119
|
describe "for #reserve" do
|
106
120
|
before do
|
107
|
-
@
|
108
|
-
@tube = @
|
121
|
+
@beanstalk = Beaneater.new('localhost')
|
122
|
+
@tube = @beanstalk.tubes.find 'tube'
|
109
123
|
@time = Time.now.to_i
|
110
124
|
@tube.put "foo reserve #{@time}"
|
111
125
|
end
|
112
126
|
|
113
127
|
it("should reserve job") do
|
114
|
-
@
|
115
|
-
job = @
|
128
|
+
@beanstalk.tubes.watch 'tube'
|
129
|
+
job = @beanstalk.tubes.reserve
|
116
130
|
assert_equal "foo reserve #{@time}", job.body
|
117
131
|
job.delete
|
118
132
|
end
|
119
133
|
|
120
134
|
it("should reserve job with block") do
|
121
|
-
@
|
135
|
+
@beanstalk.tubes.watch 'tube'
|
122
136
|
job = nil
|
123
|
-
@
|
137
|
+
@beanstalk.tubes.reserve { |j| job = j; job.delete }
|
124
138
|
assert_equal "foo reserve #{@time}", job.body
|
125
139
|
end
|
126
140
|
|
127
141
|
it("should reserve job with block and timeout") do
|
128
|
-
@
|
142
|
+
@beanstalk.tubes.watch 'tube'
|
129
143
|
job = nil
|
130
|
-
res = @
|
144
|
+
res = @beanstalk.tubes.reserve(0) { |j| job = j; job.delete }
|
131
145
|
assert_equal "foo reserve #{@time}", job.body
|
132
146
|
end
|
133
147
|
|
134
148
|
it "should raise TimedOutError with timeout" do
|
135
|
-
@
|
136
|
-
@
|
137
|
-
assert_raises(Beaneater::TimedOutError) { @
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should raise TimedOutError no delete, with timeout" do
|
141
|
-
@pool.tubes.watch 'tube'
|
142
|
-
@pool.tubes.reserve(0) { |j| job = j; job.delete }
|
143
|
-
assert_raises(Beaneater::TimedOutError) { @pool.tubes.reserve(0) }
|
149
|
+
@beanstalk.tubes.watch 'tube'
|
150
|
+
@beanstalk.tubes.reserve(0) { |j| job = j; job.delete }
|
151
|
+
assert_raises(Beaneater::TimedOutError) { @beanstalk.tubes.reserve(0) }
|
144
152
|
end
|
145
153
|
|
146
154
|
it "should raise DeadlineSoonError with ttr 1" do
|
147
155
|
@tube.reserve.delete
|
148
156
|
@tube.put "foo reserve #{@time}", :ttr => 1
|
149
|
-
@
|
150
|
-
@
|
151
|
-
assert_raises(Beaneater::DeadlineSoonError) { @
|
157
|
+
@beanstalk.tubes.watch 'tube'
|
158
|
+
@beanstalk.tubes.reserve
|
159
|
+
assert_raises(Beaneater::DeadlineSoonError) { @beanstalk.tubes.reserve(0) }
|
152
160
|
end
|
153
161
|
|
154
|
-
after do
|
155
|
-
cleanup_tubes!(['foo', 'tube'])
|
156
|
-
end
|
157
162
|
end # reserve
|
158
163
|
end # Beaneater::Tubes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaneater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Taing
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -105,8 +105,6 @@ files:
|
|
105
105
|
- lib/beaneater/job.rb
|
106
106
|
- lib/beaneater/job/collection.rb
|
107
107
|
- lib/beaneater/job/record.rb
|
108
|
-
- lib/beaneater/pool.rb
|
109
|
-
- lib/beaneater/pool_command.rb
|
110
108
|
- lib/beaneater/stats.rb
|
111
109
|
- lib/beaneater/stats/fast_struct.rb
|
112
110
|
- lib/beaneater/stats/stat_struct.rb
|
@@ -119,8 +117,6 @@ files:
|
|
119
117
|
- test/errors_test.rb
|
120
118
|
- test/job_test.rb
|
121
119
|
- test/jobs_test.rb
|
122
|
-
- test/pool_command_test.rb
|
123
|
-
- test/pool_test.rb
|
124
120
|
- test/prompt_regexp_test.rb
|
125
121
|
- test/stat_struct_test.rb
|
126
122
|
- test/stats_test.rb
|
@@ -157,8 +153,6 @@ test_files:
|
|
157
153
|
- test/errors_test.rb
|
158
154
|
- test/job_test.rb
|
159
155
|
- test/jobs_test.rb
|
160
|
-
- test/pool_command_test.rb
|
161
|
-
- test/pool_test.rb
|
162
156
|
- test/prompt_regexp_test.rb
|
163
157
|
- test/stat_struct_test.rb
|
164
158
|
- test/stats_test.rb
|
data/lib/beaneater/pool.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
# Simple ruby client for interacting with beanstalkd.
|
2
|
-
module Beaneater
|
3
|
-
# Represents collection of beanstalkd connections.
|
4
|
-
class Pool
|
5
|
-
# Default number of retries to send a command to a connection
|
6
|
-
MAX_RETRIES = 3
|
7
|
-
|
8
|
-
# @!attribute connections
|
9
|
-
# @return [Array<Beaneater::Connection>] returns Collection of connections
|
10
|
-
attr_reader :connections
|
11
|
-
|
12
|
-
# Initialize new connection
|
13
|
-
#
|
14
|
-
# @param [Array<String>] addresses Array of beanstalkd server addresses
|
15
|
-
# @example
|
16
|
-
# Beaneater::Pool.new(['localhost:11300', '127.0.0.1:11300'])
|
17
|
-
#
|
18
|
-
# ENV['BEANSTALKD_URL'] = 'localhost:11300,127.0.0.1:11300'
|
19
|
-
# @bp = Beaneater::Pool.new
|
20
|
-
# @bp.connections.first.host # => 'localhost'
|
21
|
-
# @bp.connections.last.host # => '127.0.0.1'
|
22
|
-
#
|
23
|
-
def initialize(addresses=nil)
|
24
|
-
addresses = addresses || host_from_env || Beaneater.configuration.beanstalkd_url
|
25
|
-
@connections = Array(addresses).map { |a| Connection.new(a) }
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns Beaneater::Stats object for accessing beanstalk stats.
|
29
|
-
#
|
30
|
-
# @return [Beaneater::Stats] stats object
|
31
|
-
# @api public
|
32
|
-
def stats
|
33
|
-
@stats ||= Stats.new(self)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns Beaneater::Jobs object for accessing job related functions.
|
37
|
-
#
|
38
|
-
# @return [Beaneater::Jobs] jobs object
|
39
|
-
# @api public
|
40
|
-
def jobs
|
41
|
-
@jobs ||= Jobs.new(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns Beaneater::Tubes object for accessing tube related functions.
|
45
|
-
#
|
46
|
-
# @return [Beaneater::Tubes] tubes object
|
47
|
-
# @api public
|
48
|
-
def tubes
|
49
|
-
@tubes ||= Tubes.new(self)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Sends command to every beanstalkd server set in the pool.
|
53
|
-
#
|
54
|
-
# @param [String] command Beanstalkd command
|
55
|
-
# @param [Hash{String => String, Boolean}] options socket connections options
|
56
|
-
# @param [Proc] block Block passed to socket connection during transmit
|
57
|
-
# @return [Array<Hash{String => String, Number}>] Beanstalkd command response from each instance
|
58
|
-
# @example
|
59
|
-
# @pool.transmit_to_all("stats")
|
60
|
-
#
|
61
|
-
def transmit_to_all(command, options={}, &block)
|
62
|
-
res_exception = nil
|
63
|
-
res = connections.map { |conn|
|
64
|
-
begin
|
65
|
-
safe_transmit { conn.transmit(command, options, &block) }
|
66
|
-
rescue UnexpectedResponse => ex # not the correct status
|
67
|
-
res_exception = ex
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
}.compact
|
71
|
-
raise res_exception if res.none? && res_exception
|
72
|
-
res
|
73
|
-
end
|
74
|
-
|
75
|
-
# Send command to each beanstalkd servers until getting response expected
|
76
|
-
#
|
77
|
-
# @param [String] command Beanstalkd command
|
78
|
-
# @param [Hash{String => String, Boolean}] options socket connections options
|
79
|
-
# @param [Proc] block Block passed in socket connection object
|
80
|
-
# @return [Array<Hash{String => String, Number}>] Beanstalkd command response from the instance
|
81
|
-
# @example
|
82
|
-
# @pool.transmit_until_res('peek-ready', :status => "FOUND", &block)
|
83
|
-
#
|
84
|
-
def transmit_until_res(command, options={}, &block)
|
85
|
-
status_expected = options.delete(:status)
|
86
|
-
res_exception = nil
|
87
|
-
connections.each do |conn|
|
88
|
-
begin
|
89
|
-
res = safe_transmit { conn.transmit(command, options, &block) }
|
90
|
-
return res if res[:status] == status_expected
|
91
|
-
rescue UnexpectedResponse => ex # not the correct status
|
92
|
-
res_exception = ex
|
93
|
-
next
|
94
|
-
end
|
95
|
-
end
|
96
|
-
raise res_exception if res_exception
|
97
|
-
end
|
98
|
-
|
99
|
-
# Sends command to a random beanstalkd server in the pool.
|
100
|
-
#
|
101
|
-
# @param [String] command Beanstalkd command
|
102
|
-
# @param [Hash{String => String,Boolean}] options socket connections options
|
103
|
-
# @param [Proc] block Block passed in socket connection object
|
104
|
-
# @return [Array<Hash{String => String, Number}>] Beanstalkd command response from the instance
|
105
|
-
# @example
|
106
|
-
# @pool.transmit_to_rand("stats", :match => /\n/)
|
107
|
-
#
|
108
|
-
def transmit_to_rand(command, options={}, &block)
|
109
|
-
safe_transmit do
|
110
|
-
conn = connections.respond_to?(:sample) ? connections.sample : connections.choice
|
111
|
-
conn.transmit(command, options, &block)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# Closes all connections within the pool.
|
116
|
-
#
|
117
|
-
# @example
|
118
|
-
# @pool.close
|
119
|
-
#
|
120
|
-
def close
|
121
|
-
while @connections.any?
|
122
|
-
conn = @connections.pop
|
123
|
-
conn.close
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
protected
|
128
|
-
|
129
|
-
# Transmit command to beanstalk connections safely handling failed connections
|
130
|
-
#
|
131
|
-
# @param [Proc] block The command to execute.
|
132
|
-
# @return [Object] Result of the block passed
|
133
|
-
# @raise [Beaneater::DrainingError,Beaneater::NotConnected] Could not connect to Beanstalk client
|
134
|
-
# @example
|
135
|
-
# safe_transmit { conn.transmit('foo') }
|
136
|
-
# # => "result of foo command from beanstalk"
|
137
|
-
#
|
138
|
-
def safe_transmit(&block)
|
139
|
-
retries = 1
|
140
|
-
begin
|
141
|
-
yield
|
142
|
-
rescue DrainingError, EOFError, Errno::ECONNRESET, Errno::EPIPE => ex
|
143
|
-
# TODO remove faulty connections from pool?
|
144
|
-
# https://github.com/kr/beanstalk-client-ruby/blob/master/lib/beanstalk-client/connection.rb#L405-410
|
145
|
-
if retries < MAX_RETRIES
|
146
|
-
retries += 1
|
147
|
-
retry
|
148
|
-
else # finished retrying, fail out
|
149
|
-
ex.is_a?(DrainingError) ? raise(ex) : raise(NotConnected, "Could not connect!")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end # transmit_call
|
153
|
-
|
154
|
-
# The hosts provided by BEANSTALKD_URL environment variable, if available.
|
155
|
-
#
|
156
|
-
# @return [Array] Set of beanstalkd host addresses
|
157
|
-
# @example
|
158
|
-
# ENV['BEANSTALKD_URL'] = "localhost:1212,localhost:2424"
|
159
|
-
# # => ['localhost:1212', 'localhost:2424']
|
160
|
-
#
|
161
|
-
def host_from_env
|
162
|
-
ENV['BEANSTALKD_URL'].respond_to?(:length) && ENV['BEANSTALKD_URL'].length > 0 && ENV['BEANSTALKD_URL'].split(',').map(&:strip)
|
163
|
-
end
|
164
|
-
|
165
|
-
end # Pool
|
166
|
-
end # Beaneater
|