pubsubstub 0.0.13 → 0.0.14

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
  SHA1:
3
- metadata.gz: c24dc6715b65ec7c9670dd3c8753291eed88bcdd
4
- data.tar.gz: 9b5d46e495137a629ad37b5680b35c877d3f7b7f
3
+ metadata.gz: e4106e5ee0478ce5a148b49fc03d444f77ccb539
4
+ data.tar.gz: 2683f674608bcf93cb6838afb8b877a811db663f
5
5
  SHA512:
6
- metadata.gz: 8cc525b5961d9887ae419b21643507dc10710d98732209e6d0b0c5e27a384e8e1367ccd25a5acdbe9fcd2450a4ad836b402d4485797f50d3f0c84b44a39f6667
7
- data.tar.gz: 7c3578a6f8ca36b5669a793029e5ba0e172d8fd212218a1ab0242a0dece81456927b0ab235e85bb4abbf68188b4be8cc84b74818b54139402f715ccc8cc68425
6
+ metadata.gz: 30f6b41e4fb7d60ab31668ef88ff62d136d94d21a9c12be1d918b9bd8765153e2b51603c870764d3cbf030136c961772a643addc3ae0fadf60db927a837bfa89
7
+ data.tar.gz: ab0a8ced2ccb64356c70a56503c10d12b44a8a29d87db44429694432c5301a120d83b8eca8555b3604d8e6d2a2b9e0e8fad17c3edce70e1e33e9304aec81f175
@@ -4,6 +4,7 @@ module Pubsubstub
4
4
 
5
5
  def initialize(*)
6
6
  super
7
+ start_heartbeat
7
8
  end
8
9
 
9
10
  get '/', provides: 'text/event-stream' do
@@ -16,7 +17,6 @@ module Pubsubstub
16
17
 
17
18
  if EventMachine.reactor_running?
18
19
  subscribe_connection
19
- start_heartbeat
20
20
  else
21
21
  return_scrollback
22
22
  end
@@ -62,10 +62,12 @@ module Pubsubstub
62
62
  end
63
63
 
64
64
  def start_heartbeat
65
- return if @timer
66
- @timer = EventMachine::PeriodicTimer.new(Pubsubstub.heartbeat_frequency) do
67
- event = heartbeat_event.to_message
68
- @connections.each { |connection| connection << event }
65
+ @heartbeat = Thread.new do
66
+ loop do
67
+ sleep Pubsubstub.heartbeat_frequency
68
+ event = heartbeat_event.to_message
69
+ @connections.each { |connection| connection << event }
70
+ end
69
71
  end
70
72
  end
71
73
 
@@ -1,3 +1,3 @@
1
1
  module Pubsubstub
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -106,11 +106,11 @@ describe "Pubsubstub::StreamAction with EventMachine" do
106
106
 
107
107
  event = Pubsubstub::Event.new('ping', name: 'heartbeat', retry_after: Pubsubstub::StreamAction::RECONNECT_TIMEOUT)
108
108
 
109
- EM.add_timer(0.001) {
109
+ EM.add_timer(0.002) {
110
110
  body.close
111
111
  response.finish
112
112
 
113
- expect(response.body).to eq(event.to_message)
113
+ expect(response.body).to start_with(event.to_message)
114
114
  EM.stop
115
115
  }
116
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubsubstub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Malette