beaneater 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fe3f3a885f7fd1d205f508d48e2ce588bb56d2e4
4
- data.tar.gz: 0d5578662d16fa1ad5da7f48e85f1ebf2a13d66d
2
+ SHA256:
3
+ metadata.gz: 83a6a5bc5d6a0e34828c5b011ca65b3bb99a296ab0d038b348279fd7b5bbf842
4
+ data.tar.gz: 30e307f3cb14d2d078cfc2eb23219add703535b2a2c9e8212b60dd54eb808bd9
5
5
  SHA512:
6
- metadata.gz: 532de361e18a96f6acbbb152edc7ada7e83c2793fb494e03ea8e9f0064c6d81b20dfd296fbec26731d61a944cbdc43986492ce77f3c5e4fa30a7a3158e27a185
7
- data.tar.gz: 1838fcddd8e169470a13dac5305ed0dec7b84a5fdd79289626f05a45862b4b7bce4e45cb82f455ea46ec0ed738e9003e6922b751c8f85f57aaa386e2e5b25c0f
6
+ metadata.gz: 820d14df0a37f2d3afd63db394a8d971a0e98436331a67b989e4c58335f1d3803f79b233b261c096069c511cba5ff77d7bf0eb887f14a9f61b39251d9ac8ea12
7
+ data.tar.gz: ed53e2479c36ce9e2af27f3e63a00c3540e935fcc822414649ae2135daa93d59cc14154f71c70e6d02a9f53a42d11b360fe01808350915a85b91abd8ffc95056
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ - 2.5
4
+ - 2.6
5
+ - 2.7
5
6
  before_install:
6
7
  - curl -L https://github.com/kr/beanstalkd/archive/v1.9.tar.gz | tar xz -C /tmp
7
8
  - cd /tmp/beanstalkd-1.9/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG for Beaneater
2
2
 
3
+ ## 1.1.0 (April 25th 2021)
4
+
5
+ * 'clear' behavior was failing unexpectedly, swallow issues during delete as well (@bfolkens)
6
+ * Fix assigned but unused variables (@utilum)
7
+ * Fix last_used tube not stored (@albb0920)
8
+ * Fix deprecation warning in ruby 2.7 (@albb0920)
9
+ * Fix watched tubes not restored after reconnect (@albb0920)
10
+ * Fix keyword arguemnt warning (@albb0920)
11
+
3
12
  ## 1.0.0 (April 26th 2015)
4
13
 
5
14
  * Beginning from version 1.0.0 the support for `Beaneater::Pool` has been dropped (@alup)
data/README.md CHANGED
@@ -6,7 +6,7 @@ Beaneater is the best way to interact with beanstalkd from within Ruby.
6
6
  [Beanstalkd](http://kr.github.com/beanstalkd/) is a simple, fast work queue. Its interface is generic, but was
7
7
  originally designed for reducing the latency of page views in high-volume web applications by
8
8
  running time-consuming tasks asynchronously. Read the [yardocs](http://rdoc.info/github/beanstalkd/beaneater) and/or the
9
- [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.md) for more details.
9
+ [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt) for more details.
10
10
 
11
11
  **Important Note**: This README is **for branch 1.0.x which is under development**. Please switch to latest `0.x` branch for stable version.
12
12
 
@@ -147,7 +147,7 @@ To interact with a beanstalk queue, first establish a connection by providing an
147
147
 
148
148
  # Or if ENV['BEANSTALKD_URL'] == '127.0.0.1:11300'
149
149
  @beanstalk = Beaneater.new
150
- @beanstalk.connectiont # => localhost:11300
150
+ @beanstalk.connection # => localhost:11300
151
151
  ```
152
152
 
153
153
  You can conversely close and dispose of a connection at any time with:
@@ -429,7 +429,7 @@ are listed below:
429
429
  There are other exceptions that are less common such as `OutOfMemoryError`, `DrainingError`,
430
430
  `DeadlineSoonError`, `InternalError`, `BadFormatError`, `UnknownCommandError`,
431
431
  `ExpectedCRLFError`, `JobTooBigError`, `NotIgnoredError`. Be sure to check the
432
- [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.md) for more information.
432
+ [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt) for more information.
433
433
 
434
434
 
435
435
  ### Stats
@@ -462,7 +462,7 @@ print @beanstalk.jobs[some_job_id].stats
462
462
  # => {'age': 0, 'id': 2, 'state': 'reserved', 'tube': 'default', ... }
463
463
  ```
464
464
 
465
- Be sure to check the [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.md) for
465
+ Be sure to check the [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt) for
466
466
  more details about the stats commands.
467
467
 
468
468
  ## Resources
@@ -473,7 +473,7 @@ There are other resources helpful when learning about beanstalk:
473
473
  * [Beaneater on Rubygems](https://rubygems.org/gems/beaneater)
474
474
  * [Beanstalkd homepage](http://kr.github.com/beanstalkd/)
475
475
  * [beanstalk on github](https://github.com/kr/beanstalkd)
476
- * [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.md)
476
+ * [beanstalk protocol](https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt)
477
477
  * [Backburner](https://github.com/nesquena/backburner) - Ruby job queue for Rails/Sinatra
478
478
  * [BeanCounter](https://github.com/gemeraldbeanstalk/bean_counter) - TestUnit/MiniTest assertions and RSpec matchers for testing code that relies on Beaneater
479
479
 
data/lib/beaneater.rb CHANGED
@@ -21,7 +21,7 @@ class Beaneater
21
21
  # @b.connection.host # => '127.0.0.1'
22
22
  # @b.connection.port # => '11300'
23
23
  #
24
- def initialize(address)
24
+ def initialize(address=nil)
25
25
  @connection = Connection.new(address)
26
26
  end
27
27
 
@@ -82,4 +82,4 @@ class Beaneater
82
82
  @_configuration ||= Configuration.new
83
83
  end
84
84
  end
85
- end # Beaneater
85
+ end # Beaneater
@@ -69,8 +69,8 @@ class Beaneater
69
69
  # @conn.transmit('bury 123')
70
70
  # @conn.transmit('stats')
71
71
  #
72
- def transmit(command, options={})
73
- _with_retry(options[:retry_interval], options[:init]) do
72
+ def transmit(command, **options)
73
+ _with_retry(**options.slice(:retry_interval, :init)) do
74
74
  @mutex.synchronize do
75
75
  _raise_not_connected! unless connection
76
76
 
@@ -175,6 +175,8 @@ class Beaneater
175
175
  tubes_watched.each do |t|
176
176
  transmit("watch #{t}", init: false)
177
177
  end
178
+
179
+ transmit("ignore default", init: false)
178
180
  end
179
181
 
180
182
  transmit("use #{tube_used}", init: false) if @tube_used != 'default'
@@ -187,7 +189,7 @@ class Beaneater
187
189
  # @param [Integer] tries The maximum number of tries in draining mode
188
190
  # @return [Object] Result of the block passed
189
191
  #
190
- def _with_retry(retry_interval, init=true, tries=MAX_RETRIES, &block)
192
+ def _with_retry(retry_interval: DEFAULT_RETRY_INTERVAL, init: true, tries: MAX_RETRIES, &block)
191
193
  yield
192
194
  rescue EOFError, Errno::ECONNRESET, Errno::EPIPE,
193
195
  Errno::ECONNREFUSED => ex
@@ -200,7 +202,7 @@ class Beaneater
200
202
  close
201
203
  raise
202
204
  end
203
- sleep(retry_interval || DEFAULT_RETRY_INTERVAL)
205
+ sleep(retry_interval)
204
206
  retry
205
207
  end
206
208
 
@@ -69,7 +69,7 @@ class Beaneater
69
69
  class ExpectedCrlfError < UnexpectedResponse; end
70
70
  # Raises when the body of a job was too large.
71
71
  class JobTooBigError < UnexpectedResponse; end
72
- # Raises when a job was attempted to be reserved but the timeout occured.
72
+ # Raises when a job was attempted to be reserved but the timeout occurred.
73
73
  class TimedOutError < UnexpectedResponse; end
74
74
  # Raises when a tube could not be ignored because it is the last watched tube.
75
75
  class NotIgnoredError < UnexpectedResponse; end
@@ -29,8 +29,8 @@ class Beaneater
29
29
  # Delegates transmit to the connection object.
30
30
  #
31
31
  # @see Beaneater::Connection#transmit
32
- def transmit(command, options={})
33
- client.connection.transmit(command, options)
32
+ def transmit(command, **options)
33
+ client.connection.transmit(command, **options)
34
34
  end
35
35
 
36
36
  # Finds the specified beanstalk tube.
@@ -88,8 +88,8 @@ class Beaneater
88
88
  # @pool.tubes.each {|t| puts t.name}
89
89
  #
90
90
  # @api public
91
- def each
92
- block_given? ? all.each(&Proc.new) : all.each
91
+ def each(&block)
92
+ all.each(&block)
93
93
  end
94
94
 
95
95
  # List of watched beanstalk tubes.
@@ -175,7 +175,7 @@ class Beaneater
175
175
  def use(tube)
176
176
  return tube if last_used == tube
177
177
  transmit("use #{tube}")
178
- last_used = tube
178
+ self.last_used = tube
179
179
  rescue BadFormatError
180
180
  raise InvalidTubeName, "Tube cannot be named '#{tube}'"
181
181
  end
@@ -133,11 +133,15 @@ class Beaneater
133
133
  client.tubes.watch!(self.name)
134
134
  %w(delayed buried ready).each do |state|
135
135
  while job = self.peek(state.to_sym)
136
- job.delete
136
+ begin
137
+ job.delete
138
+ rescue Beaneater::UnexpectedResponse, Beaneater::NotFoundError
139
+ # swallow any issues
140
+ end
137
141
  end
138
142
  end
139
143
  client.tubes.ignore(name)
140
- rescue Beaneater::UnexpectedResponse
144
+ rescue Beaneater::NotIgnoredError
141
145
  # swallow any issues
142
146
  end
143
147
 
@@ -1,4 +1,4 @@
1
1
  class Beaneater
2
2
  # Current version of gem.
3
- VERSION = "1.0.0"
4
- end
3
+ VERSION = "1.1.0"
4
+ end
@@ -96,6 +96,24 @@ describe Beaneater::Connection do
96
96
 
97
97
  assert_raises(Beaneater::NotConnected) { @bc.transmit "delete 56\r\n" }
98
98
  end
99
+
100
+ it "tubes_watched are restored after reconnect" do
101
+ client = Beaneater.new('127.0.0.1:11300')
102
+ client.tubes.watch! "another"
103
+
104
+ TCPSocket.prepend Module.new {
105
+ def readline
106
+ if !$called
107
+ $called = true
108
+ raise EOFError
109
+ end
110
+
111
+ super
112
+ end
113
+ }
114
+
115
+ assert_equal %w[another], client.tubes.watched.map(&:name)
116
+ end
99
117
  end # transmit
100
118
 
101
119
  describe 'for #close' do
data/test/tube_test.rb CHANGED
@@ -191,7 +191,7 @@ describe Beaneater::Tube do
191
191
  tube_counts = lambda { %w(ready buried delayed).map { |s| @tube.stats["current_jobs_#{s}"] } }
192
192
  assert_equal [2, 2, 2], tube_counts.call
193
193
  @tube.clear
194
- stats = @tube.stats
194
+ @tube.stats
195
195
  assert_equal [0, 0, 0], tube_counts.call
196
196
  end
197
197
  end # clear
data/test/tubes_test.rb CHANGED
@@ -20,7 +20,7 @@ describe Beaneater::Tubes do
20
20
  end
21
21
 
22
22
  it "should switch to used tube for valid name" do
23
- tube = Beaneater::Tube.new(@beanstalk, 'some_name')
23
+ Beaneater::Tube.new(@beanstalk, 'some_name')
24
24
  @beanstalk.tubes.use('some_name')
25
25
  assert_equal 'some_name', @beanstalk.tubes.used.name
26
26
  end
@@ -141,7 +141,7 @@ describe Beaneater::Tubes do
141
141
  it("should reserve job with block and timeout") do
142
142
  @beanstalk.tubes.watch 'tube'
143
143
  job = nil
144
- res = @beanstalk.tubes.reserve(0) { |j| job = j; job.delete }
144
+ @beanstalk.tubes.reserve(0) { |j| job = j; job.delete }
145
145
  assert_equal "foo reserve #{@time}", job.body
146
146
  end
147
147
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaneater
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Taing
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.1.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: term-ansicolor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Simple beanstalkd client for ruby
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .travis.yml
92
- - .yardopts
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - ".yardopts"
93
93
  - CHANGELOG.md
94
94
  - Gemfile
95
95
  - LICENSE.txt
@@ -127,24 +127,23 @@ homepage: ''
127
127
  licenses:
128
128
  - MIT
129
129
  metadata: {}
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths:
133
133
  - lib
134
134
  required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - '>='
141
+ - - ">="
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.0.6
147
- signing_key:
145
+ rubygems_version: 3.0.8
146
+ signing_key:
148
147
  specification_version: 4
149
148
  summary: Simple beanstalkd client for ruby.
150
149
  test_files:
@@ -159,4 +158,3 @@ test_files:
159
158
  - test/test_helper.rb
160
159
  - test/tube_test.rb
161
160
  - test/tubes_test.rb
162
- has_rdoc: