slack-ruby-client 0.14.3 → 0.14.4

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
2
  SHA256:
3
- metadata.gz: 52a5d3c9923ec690ce3051c29b1dbf352a51ddc767fe97b073e57d1475bc62c0
4
- data.tar.gz: 573ca30fa89b54863b445bc4132382f9b2c7d9ec5054e24d0ca8998aed43d1d2
3
+ metadata.gz: cf802522f0f9aa42f83506227b02fcf37beb861429316f9ae2155d3eedde79d8
4
+ data.tar.gz: 5a81c7017616999820506cdff2af962ecbb601931f04da9598bdc9767307769b
5
5
  SHA512:
6
- metadata.gz: 54c5b782b45afb9268adfe9511b622d28d9d1e17db1e3cbdec0ffc6490870ef8ce7c12b9d20f1f580991bae9824e32a803509fca7acd912ad0dd2b9ce193ffb4
7
- data.tar.gz: 513a1fe8c32d952a9ac6c5a848e63ccfcd372616434f4aba62e00cdf107dea191c4bfa072acde577ca5df4f7aa29b86225419741a0f203bb73f92e488f443338
6
+ metadata.gz: e648e70aed991cba05dce9cc9907771d8b13c69ecab9386093460d8d3547e0fc825393d174dee7bddf1fcef15b8f85b496ae9a24cadacc4a7054db775508527a
7
+ data.tar.gz: e8397379744685f4880c20afdadaf9c19439ea9f4cb0c362e596849416f67f836686626f65af81e5ce933c2eeb9c33117fcb8f64bb6967be4963f6a477f61910
@@ -1,3 +1,8 @@
1
+ ### 0.14.4 (2019/7/28)
2
+
3
+ * [#289](https://github.com/slack-ruby/slack-ruby-client/pull/289): Fix reconnects when ping timers under/overshoot - [@georgyangelov](https://github.com/georgyangelov).
4
+ * [#290](https://github.com/slack-ruby/slack-ruby-client/pull/290): Expose Slack::RealTime::Client.logger accessor publicly - [@jcraigk](https://github.com/jcraigk).
5
+
1
6
  ### 0.14.3 (2019/7/23)
2
7
 
3
8
  * [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Prevent ping worker from dying on unexpected errors - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -66,7 +66,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
66
66
 
67
67
  ## Stable Release
68
68
 
69
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.14.3. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
69
+ You're reading the documentation for the **stable** release of slack-ruby-client, 0.14.4. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
70
70
 
71
71
  ## Installation
72
72
 
@@ -374,9 +374,11 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
374
374
  ##### `websocket_ping`
375
375
  This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
376
376
 
377
- It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping`; the client will attempt to reestablish it's connection to the message server.
377
+ It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping` the client will attempt to reestablish it's connection to the message server.
378
378
 
379
- To disable this feature; set `websocket_ping` to 0.
379
+ Note that the ping may take between `websocket_ping` and `websocket_ping * 3/2` seconds to actually trigger when there is no activity on the socket. This is because the timer that checks whether to ping is triggered at every `websocket_ping / 2` interval.
380
+
381
+ To disable this feature set `websocket_ping` to 0.
380
382
 
381
383
  ### Connection Methods
382
384
 
@@ -19,8 +19,8 @@ module Slack
19
19
  attr_accessor :store
20
20
  attr_accessor :url
21
21
  attr_accessor(*Config::ATTRIBUTES)
22
+ attr_accessor :logger
22
23
 
23
- protected :logger, :logger=
24
24
  protected :store_class, :store_class=
25
25
 
26
26
  def initialize(options = {})
@@ -139,6 +139,10 @@ module Slack
139
139
  !websocket_ping.nil? && websocket_ping > 0
140
140
  end
141
141
 
142
+ def websocket_ping_timer
143
+ websocket_ping / 2
144
+ end
145
+
142
146
  def to_s
143
147
  if store && store.team
144
148
  "id=#{store.team.id}, name=#{store.team.name}, domain=#{store.team.domain}"
@@ -34,7 +34,7 @@ module Slack
34
34
 
35
35
  # The timer task will naturally exit after the driver is set to nil.
36
36
  while @restart
37
- subtask.sleep client.websocket_ping
37
+ subtask.sleep client.websocket_ping_timer
38
38
  client.run_ping! if @restart
39
39
  end
40
40
  end
@@ -82,7 +82,7 @@ module Slack
82
82
  def run_ping_loop
83
83
  return unless @client.run_ping?
84
84
 
85
- @ping_timer = every @client.websocket_ping do
85
+ @ping_timer = every @client.websocket_ping_timer do
86
86
  @client.run_ping!
87
87
  end
88
88
  end
@@ -30,7 +30,7 @@ module Slack
30
30
  @thread = ensure_reactor_running
31
31
 
32
32
  if client.run_ping?
33
- EventMachine.add_periodic_timer(client.websocket_ping) do
33
+ EventMachine.add_periodic_timer client.websocket_ping_timer do
34
34
  client.run_ping!
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = '0.14.3'.freeze
2
+ VERSION = '0.14.4'.freeze
3
3
  end
@@ -123,7 +123,7 @@ RSpec.describe 'integration test', skip: (!ENV['SLACK_API_TOKEN'] || !ENV['CONCU
123
123
 
124
124
  context 'with websocket_ping set' do
125
125
  before do
126
- client.websocket_ping = 1
126
+ client.websocket_ping = 5
127
127
  end
128
128
 
129
129
  it 'sends pings' do
@@ -136,18 +136,20 @@ RSpec.describe 'integration test', skip: (!ENV['SLACK_API_TOKEN'] || !ENV['CONCU
136
136
 
137
137
  start_server
138
138
 
139
- queue.pop_with_timeout(5)
140
- expect(@reply_to).to be 1
139
+ queue.pop_with_timeout(10)
140
+ expect(@reply_to).to eq 1
141
141
  end
142
142
 
143
143
  it 'rebuilds the websocket connection when dropped' do
144
144
  @reply_to = nil
145
145
  client.on :pong do |data|
146
+ logger.info data
146
147
  @reply_to = data.reply_to
147
148
  if @reply_to == 1
148
149
  client.instance_variable_get(:@socket).close
150
+ queue.push :close
149
151
  else
150
- expect(@reply_to).to be 2
152
+ expect(@reply_to).to eq 2
151
153
  queue.push :pong
152
154
  client.stop!
153
155
  end
@@ -155,8 +157,10 @@ RSpec.describe 'integration test', skip: (!ENV['SLACK_API_TOKEN'] || !ENV['CONCU
155
157
 
156
158
  start_server
157
159
 
158
- queue.pop_with_timeout(10)
159
- queue.pop_with_timeout(10)
160
+ 4.times do |i|
161
+ queue.pop_with_timeout(10)
162
+ client.logger.info "Pop #{i}"
163
+ end
160
164
  end
161
165
  end
162
166
 
@@ -42,6 +42,20 @@ RSpec.describe Slack::RealTime::Client do
42
42
  end
43
43
  end
44
44
  end
45
+ context 'websocket_ping_timer' do
46
+ context 'with defaults' do
47
+ let(:client) { Slack::RealTime::Client.new }
48
+ it 'defaults to websocket_ping / 2' do
49
+ expect(client.websocket_ping_timer).to eq 15
50
+ end
51
+ end
52
+ context 'with websocket_ping value changed' do
53
+ let(:client) { Slack::RealTime::Client.new(websocket_ping: 22) }
54
+ it 'defaults to websocket_ping / 2' do
55
+ expect(client.websocket_ping_timer).to eq 11
56
+ end
57
+ end
58
+ end
45
59
  context 'client with a full store', vcr: { cassette_name: 'web/rtm_start', allow_playback_repeats: true } do
46
60
  let(:client) { Slack::RealTime::Client.new(store_class: Slack::RealTime::Stores::Store) }
47
61
  let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
@@ -314,6 +328,15 @@ RSpec.describe Slack::RealTime::Client do
314
328
  end
315
329
  end
316
330
  end
331
+ describe 'logger accessor' do
332
+ let(:client) { Slack::RealTime::Client.new }
333
+ it 'exposes public logger' do
334
+ expect(client.logger).to be_a(::Logger)
335
+ end
336
+ it 'exposes public logger=' do
337
+ expect { client.logger = nil }.not_to raise_error(NoMethodError)
338
+ end
339
+ end
317
340
  end
318
341
  context 'global config' do
319
342
  after do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.3
4
+ version: 0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-23 00:00:00.000000000 Z
11
+ date: 2019-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport