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 +4 -4
- data/lib/pubsubstub/stream_action.rb +7 -5
- data/lib/pubsubstub/version.rb +1 -1
- data/spec/stream_action_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4106e5ee0478ce5a148b49fc03d444f77ccb539
|
4
|
+
data.tar.gz: 2683f674608bcf93cb6838afb8b877a811db663f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
|
data/lib/pubsubstub/version.rb
CHANGED
data/spec/stream_action_spec.rb
CHANGED
@@ -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.
|
109
|
+
EM.add_timer(0.002) {
|
110
110
|
body.close
|
111
111
|
response.finish
|
112
112
|
|
113
|
-
expect(response.body).to
|
113
|
+
expect(response.body).to start_with(event.to_message)
|
114
114
|
EM.stop
|
115
115
|
}
|
116
116
|
end
|