message_bus 2.2.0.pre.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of message_bus might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 036d535a40564744ade660423b59504db0f00dcdabfc74b910c7d0e162ce38a4
4
- data.tar.gz: 0f716e13a98688301af3531c5f1a48b327139b972cc97b3fceb989855707e0a5
3
+ metadata.gz: 99317ae05b998644cb03be9365caf40fb7375426ea0bbbc1a165a3d6b10edf57
4
+ data.tar.gz: 3a0101abb11820b6225eefe0c2ac318502e05a8e2b6e0a4116adfed4b2a53864
5
5
  SHA512:
6
- metadata.gz: 41c0e801c22728e69711c6cc70c387eaf64bcc9f3b3850eddea0ac576b5efe6eb244a0d6021bb20ad56f693fd05b0a9fc52a5492d04a80fa1f0656f9c0464035
7
- data.tar.gz: c3ab4459396a7706987af51019eacafe61915a7c0bb60e43832e55c0c05f08a3280ac6cd41f4eccb2321ae4d931f7700633c46b0da828cb25254997c96b0cc53
6
+ metadata.gz: b1aca6d2cad3da7eb43febac4538396a14824cf3638afe28b1d20470b8a01b52a26039102fa87dde502d3aac4cf0c12030b8c21145aaeb591573f190765aae3e
7
+ data.tar.gz: c5eaac3ab21f72c235c2d408d054e0c3423f619bc298d04402e3e101517944d74bcc799fa240ce7ec11187478dc78f87875293d53998e04edb5aa62c5a3a6f9f
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  Unreleased
2
2
 
3
+ 28-01-2019
4
+
5
+ - Version 2.2.0
6
+
7
+ - FIX: Ruby HTTP Client not backing off polling on error.
8
+
3
9
  11-12-2018
4
10
 
5
11
  - Version 2.2.0.pre.2
@@ -22,11 +22,11 @@ module MessageBus
22
22
  # @!attribute enable_chunked_encoding
23
23
  # @return [Boolean] whether chunked encoding is enabled
24
24
  # @!attribute min_poll_interval
25
- # @return [Float] the min poll interval for long polling
25
+ # @return [Float] the min poll interval for long polling in seconds
26
26
  # @!attribute max_poll_interval
27
- # @return [Float] the max poll interval for long polling
27
+ # @return [Float] the max poll interval for long polling in seconds
28
28
  # @!attribute background_callback_interval
29
- # @return [Float] the polling interval
29
+ # @return [Float] the polling interval in seconds
30
30
  class HTTPClient
31
31
  class InvalidChannel < StandardError; end
32
32
  class MissingBlock < StandardError; end
@@ -55,11 +55,11 @@ module MessageBus
55
55
  # @param base_url [String] Base URL of the message_bus server to connect to
56
56
  # @param enable_long_polling [Boolean] Enable long polling
57
57
  # @param enable_chunked_encoding [Boolean] Enable chunk encoding
58
- # @param min_poll_interval [Float, Integer] Min poll interval when long polling
59
- # @param max_poll_interval [Float, Integer] Max poll interval when long polling.
58
+ # @param min_poll_interval [Float, Integer] Min poll interval when long polling in seconds
59
+ # @param max_poll_interval [Float, Integer] Max poll interval when long polling in seconds.
60
60
  # When requests fail, the client will backoff and this is the upper limit.
61
61
  # @param background_callback_interval [Float, Integer] Interval to poll when
62
- # when polling.
62
+ # when polling in seconds.
63
63
  # @param headers [Hash] extra HTTP headers to be set on the polling requests.
64
64
  #
65
65
  # @return [Object] Instance of MessageBus::HTTPClient
@@ -113,6 +113,7 @@ module MessageBus
113
113
  rescue StandardError => e
114
114
  @stats.failed += 1
115
115
  warn("#{e.class} #{e.message}: #{e.backtrace.join("\n")}")
116
+ sleep interval
116
117
  retry
117
118
  ensure
118
119
  stop
@@ -226,7 +227,7 @@ module MessageBus
226
227
  def interval
227
228
  if @enable_long_polling
228
229
  if (failed_count = @stats.failed) > 2
229
- (@min_poll_interval * failed_count).clamp(
230
+ (@min_poll_interval * 2**failed_count).clamp(
230
231
  @min_poll_interval, @max_poll_interval
231
232
  )
232
233
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MessageBus
4
- VERSION = "2.2.0.pre.2"
4
+ VERSION = "2.2.0"
5
5
  end
@@ -40,6 +40,41 @@ describe MessageBus::HTTPClient do
40
40
 
41
41
  assert_equal(new_threads, Thread.list - threads)
42
42
  end
43
+
44
+ describe 'when an error is encountered while trying to poll' do
45
+ let(:base_url) { "http://0.0.0.0:12312123" }
46
+
47
+ let(:client) do
48
+ MessageBus::HTTPClient.new(base_url, min_poll_interval: 1)
49
+ end
50
+
51
+ it 'should handle errors correctly' do
52
+ begin
53
+ original_stderr = $stderr
54
+ $stderr = fake = StringIO.new
55
+
56
+ client.channels[channel] = MessageBus::HTTPClient::Channel.new(
57
+ callbacks: [-> {}]
58
+ )
59
+
60
+ client.start
61
+
62
+ assert_equal(MessageBus::HTTPClient::STARTED, client.status)
63
+
64
+ while stats.failed < 1 do
65
+ sleep 0.05
66
+ end
67
+
68
+ # Sleep for more than the default min_poll_interval to ensure
69
+ # that we sleep for the right interval after failure
70
+ sleep 0.5
71
+
72
+ assert_equal(1, fake.string.scan("Errno::ECONNREFUSED").size)
73
+ ensure
74
+ $stderr = original_stderr
75
+ end
76
+ end
77
+ end
43
78
  end
44
79
 
45
80
  describe '#subscribe' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.pre.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2019-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -151,9 +151,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  version: 2.3.0
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - ">"
154
+ - - ">="
155
155
  - !ruby/object:Gem::Version
156
- version: 1.3.1
156
+ version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 2.7.6