beaneater 0.3.0 → 0.3.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 454588f4369a9102f949a43c73d7fe8d06de5191
4
+ data.tar.gz: e7655c12db30696d1feb41b1f3c6de9c4100115c
5
+ SHA512:
6
+ metadata.gz: e523bcdfeb277ed363335be20de8d7114680fe7fa98a7b8a3f7e341547dd0b41290fba35fece3615bd6839ef9381ee8312aac003662e5b2afc4accfdbfa00fbd
7
+ data.tar.gz: 0e0d48e4514d953d2acc4bce929a08201912c8f04dc14b0f70bd2ccaa7f7ca2dfbd91ac73156a8542c374fed1b963bd910abe65cfd561d7ff24b7323f1875ff6
@@ -1,6 +1,12 @@
1
1
  # CHANGELOG for Beaneater
2
2
 
3
- ## 0.3.1 (Unreleased)
3
+ ## 0.3.2 (Unreleased)
4
+
5
+ ## 0.3.1 (Jun 28 2013)
6
+
7
+ * Fixes issue with "chomp" nil exception when losing connection (Thanks @simao)
8
+ * Better handling of unknown or invalid commands during transmit
9
+ * Raise proper CRLF exception (Thanks @carlosmoutinho)
4
10
 
5
11
  ## 0.3.0 (Jan 23 2013)
6
12
 
data/README.md CHANGED
@@ -264,7 +264,7 @@ In order to process jobs, the client should first specify the intended tubes to
264
264
  this will default to watching just the `default` tube.
265
265
 
266
266
  ```ruby
267
- @beanstalk = Beaneater::Connection.new(['10.0.1.5:11300'])
267
+ @beanstalk = Beaneater::Pool.new(['10.0.1.5:11300'])
268
268
  @beanstalk.tubes.watch!('tube-name', 'other-tube')
269
269
  ```
270
270
 
@@ -390,7 +390,9 @@ Processing runs the following steps:
390
390
  1. If other exception occurs, call 'bury' (error)
391
391
  1. Repeat steps 2-5
392
392
 
393
- The `process` command is ideally suited for a beanstalk job processing daemon.
393
+ The `process!` command is ideally suited for a beanstalk job processing daemon.
394
+ Even though `process!` is intended to be a long-running process, you can stop the loop at any time
395
+ by raising `AbortProcessingError` while processing is running.
394
396
 
395
397
  ### Handling Errors
396
398
 
@@ -459,4 +461,5 @@ There are other resources helpful when learning about beanstalk:
459
461
 
460
462
  - [Nico Taing](https://github.com/Nico-Taing) - Creator and co-maintainer
461
463
  - [Nathan Esquenazi](https://github.com/nesquena) - Contributor and co-maintainer
462
- - [Keith Rarick](https://github.com/kr) - Much code inspired and adapted from beanstalk-client
464
+ - [Keith Rarick](https://github.com/kr) - Much code inspired and adapted from beanstalk-client
465
+ - [Vidar Hokstad](https://github.com/vidarh) - Replaced telnet with correct TCP socket handling
@@ -19,7 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.add_development_dependency 'minitest', "~> 4.1.0"
20
20
  gem.add_development_dependency 'rake'
21
21
  gem.add_development_dependency 'mocha'
22
- gem.add_development_dependency 'fakeweb'
23
22
  gem.add_development_dependency 'term-ansicolor'
24
23
  gem.add_development_dependency 'json'
25
24
  end
@@ -46,16 +46,17 @@ module Beaneater
46
46
  # @conn.transmit('bury 123')
47
47
  #
48
48
  def transmit(command, options={})
49
- @mutex.lock
50
- if connection
51
- command = command.force_encoding('ASCII-8BIT') if command.respond_to?(:force_encoding)
52
- connection.write(command+"\r\n")
53
- parse_response(command, connection.gets)
54
- else # no connection
55
- raise NotConnected, "Connection to beanstalk '#{@host}:#{@port}' is closed!" unless connection
49
+ @mutex.synchronize do
50
+ if connection
51
+ command = command.force_encoding('ASCII-8BIT') if command.respond_to?(:force_encoding)
52
+ connection.write(command.to_s + "\r\n")
53
+ res = connection.gets
54
+ raise_not_connected! unless res
55
+ parse_response(command, res)
56
+ else # no connection
57
+ raise_not_connected!
58
+ end
56
59
  end
57
- ensure
58
- @mutex.unlock
59
60
  end
60
61
 
61
62
  # Close connection with beanstalkd server.
@@ -135,5 +136,10 @@ module Beaneater
135
136
  Beaneater.configuration
136
137
  end
137
138
 
139
+ # Raises an error to be triggered when the connection has failed
140
+ # @raise [Beaneater::NotConnected] Beanstalkd is no longer connected
141
+ def raise_not_connected!
142
+ raise NotConnected, "Connection to beanstalk '#{@host}:#{@port}' is closed!"
143
+ end
138
144
  end # Connection
139
145
  end # Beaneater
@@ -66,11 +66,11 @@ module Beaneater
66
66
  # Raises when a command was sent that is unknown.
67
67
  class UnknownCommandError < UnexpectedResponse; end
68
68
  # Raises when command does not have proper CRLF suffix.
69
- class ExpectedCRLFError < UnexpectedResponse; end
69
+ class ExpectedCrlfError < UnexpectedResponse; end
70
70
  # Raises when the body of a job was too large.
71
71
  class JobTooBigError < UnexpectedResponse; end
72
72
  # Raises when a job was attempted to be reserved but the timeout occured.
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
76
- end
76
+ end
@@ -1,4 +1,4 @@
1
1
  module Beaneater
2
2
  # Current version of gem.
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
@@ -23,4 +23,11 @@ describe "Beaneater::Errors" do
23
23
  assert_equal 'reserve 0', @klazz.cmd
24
24
  assert_equal 'DEADLINE_SOON', @klazz.status
25
25
  end
26
- end
26
+
27
+ it 'should raise proper exception for invalid status EXPECTED_CRLF' do
28
+ @klazz = Beaneater::UnexpectedResponse.from_status("EXPECTED_CRLF", "reserve 0")
29
+ assert_kind_of(Beaneater::ExpectedCrlfError, @klazz)
30
+ assert_equal 'reserve 0', @klazz.cmd
31
+ assert_equal 'EXPECTED_CRLF', @klazz.status
32
+ end
33
+ end
@@ -38,6 +38,11 @@ describe Beaneater::Pool do
38
38
  end
39
39
  end
40
40
 
41
+ it "raises UnexpectedException when any Exception occurs inside the block" do
42
+ invalid_command = nil
43
+ assert_raises(Beaneater::UnknownCommandError) { @bp.transmit_to_rand(invalid_command) }
44
+ end
45
+
41
46
  describe "for clearing watch list" do
42
47
  it "should clear connections of tube watches" do
43
48
  @bp.tubes.watch!('foo', 'bar')
@@ -3,12 +3,10 @@ require 'rubygems'
3
3
  require 'minitest/autorun'
4
4
  $:.unshift File.expand_path("../../lib")
5
5
  require 'beaneater'
6
- require 'fakeweb'
6
+ require 'timeout'
7
7
  require 'mocha'
8
8
  require 'json'
9
9
 
10
- FakeWeb.allow_net_connect = false
11
-
12
10
  class MiniTest::Unit::TestCase
13
11
 
14
12
  # Cleans up all jobs from tubes
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaneater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nico Taing
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
11
+ date: 2013-06-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: minitest
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,81 +27,57 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: mocha
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: fakeweb
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
52
+ - - '>='
76
53
  - !ruby/object:Gem::Version
77
54
  version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: term-ansicolor
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
- - - ! '>='
59
+ - - '>='
84
60
  - !ruby/object:Gem::Version
85
61
  version: '0'
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
- - - ! '>='
66
+ - - '>='
92
67
  - !ruby/object:Gem::Version
93
68
  version: '0'
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: json
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
- - - ! '>='
73
+ - - '>='
100
74
  - !ruby/object:Gem::Version
101
75
  version: '0'
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
- - - ! '>='
80
+ - - '>='
108
81
  - !ruby/object:Gem::Version
109
82
  version: '0'
110
83
  description: Simple beanstalkd client for ruby
@@ -155,33 +128,26 @@ files:
155
128
  - test/tubes_test.rb
156
129
  homepage: ''
157
130
  licenses: []
131
+ metadata: {}
158
132
  post_install_message:
159
133
  rdoc_options: []
160
134
  require_paths:
161
135
  - lib
162
136
  required_ruby_version: !ruby/object:Gem::Requirement
163
- none: false
164
137
  requirements:
165
- - - ! '>='
138
+ - - '>='
166
139
  - !ruby/object:Gem::Version
167
140
  version: '0'
168
- segments:
169
- - 0
170
- hash: -394754542791428871
171
141
  required_rubygems_version: !ruby/object:Gem::Requirement
172
- none: false
173
142
  requirements:
174
- - - ! '>='
143
+ - - '>='
175
144
  - !ruby/object:Gem::Version
176
145
  version: '0'
177
- segments:
178
- - 0
179
- hash: -394754542791428871
180
146
  requirements: []
181
147
  rubyforge_project:
182
- rubygems_version: 1.8.24
148
+ rubygems_version: 2.0.2
183
149
  signing_key:
184
- specification_version: 3
150
+ specification_version: 4
185
151
  summary: Simple beanstalkd client for ruby.
186
152
  test_files:
187
153
  - test/beaneater_test.rb