sse-rails-engine 1.3.0 → 1.3.1

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: 0bab1f8bb9471deacf8e724b2763a6f21c20f350
4
- data.tar.gz: ea78faac1bb777ce07993f90043358edd9b1a57d
3
+ metadata.gz: 610475d7224867bda65d90174bd8edc8f5c4d1c8
4
+ data.tar.gz: 8794db9b9d153d5be6d49ae7ad517d5c412b3e4a
5
5
  SHA512:
6
- metadata.gz: 4d67d7f168f7d0cbd71ecf18f4311e48c56e5c0c7fa1e7303076321da994e0049a2a2472be12d15a31d395309119a032a061b88cbb91a55c2787535ff69bc518
7
- data.tar.gz: f9a240475088861184a371d25441371f4a35bc7c606222bae0ddac50027746556f9661ce9f21fc5ca4008200f8471912d9e0a3a69a527aa3f0c90f0f5b72343d
6
+ metadata.gz: b2355c4e7859f8f3fb674d191b5e1167bc5555bc7f1483716646772d16fba10dc9b691669556d7344771381f2d1b3e5da6aeee9d9856f365fe134535cc302c52
7
+ data.tar.gz: c776711df39057100c8e08f8383c253ed9fff521b1954b767cb9076e1bcaa48931b038e6c66ce101b93d0792990c309fd24784d00bfd32419853398eb4a7f90d
@@ -1,6 +1,6 @@
1
1
  module SseRailsEngine
2
2
  class Connection
3
- attr_accessor :stream
3
+ attr_accessor :stream, :channels
4
4
 
5
5
  SSE_HEADER = ["HTTP/1.1 200 OK\r\n",
6
6
  "Content-Type: text/event-stream\r\n",
@@ -9,6 +9,7 @@ module SseRailsEngine
9
9
  "\r\n"].join.freeze
10
10
 
11
11
  def initialize(io, env)
12
+ clear_active_db_connections
12
13
  @socket = io
13
14
  @socket.write SSE_HEADER
14
15
  @socket.flush
@@ -32,5 +33,10 @@ module SseRailsEngine
32
33
  def requested_channels(env)
33
34
  Rack::Utils.parse_query(env['QUERY_STRING']).fetch('channels', []).split(',').flatten
34
35
  end
36
+
37
+ def clear_active_db_connections
38
+ return unless defined? ActiveRecord::Base.clear_active_connections!
39
+ ActiveRecord::Base.clear_active_connections!
40
+ end
35
41
  end
36
42
  end
@@ -40,7 +40,7 @@ module SseRailsEngine
40
40
  @connections.dup.each do |stream, connection|
41
41
  begin
42
42
  connection.write(name, data)
43
- rescue IOError, Errno::EPIPE, Errno::ETIMEDOUT => ex
43
+ rescue => ex
44
44
  Rails.logger.debug "SSE Client disconnected: #{stream} - #{ex.message}"
45
45
  close_connection(stream)
46
46
  end
@@ -49,9 +49,9 @@ module SseRailsEngine
49
49
  end
50
50
 
51
51
  def open_connection(io, env)
52
- Rails.logger.debug "New SSE Client connected: #{io}"
53
52
  @mutex.synchronize do
54
53
  @connections[io] = Connection.new(io, env)
54
+ Rails.logger.debug "New SSE Client connected: #{io} - #{@connections[io].channels}"
55
55
  end
56
56
  end
57
57
 
@@ -1,3 +1,3 @@
1
1
  module SseRailsEngine
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -564,3 +564,53 @@ New SSE Client connected: #<StringIO:0x007fdd7a8daf18>
564
564
  SSE Client disconnected: #<StringIO:0x007fdd7a8daf18> - IOError
565
565
  Starting SSE heartbeat thread!
566
566
  New SSE Client connected: #<StringIO:0x007fdd7a8d27c8>
567
+ Starting SSE heartbeat thread!
568
+ Starting SSE heartbeat thread!
569
+ New SSE Client connected: #<StringIO:0x007f882b4d9440>
570
+ Starting SSE heartbeat thread!
571
+ New SSE Client connected: #<StringIO:0x007f882b4d1510>
572
+ SSE Client disconnected: #<StringIO:0x007f882b4d1510> - IOError
573
+ Starting SSE heartbeat thread!
574
+ Starting SSE heartbeat thread!
575
+ New SSE Client connected: #<StringIO:0x007f882b4c1d18>
576
+ New SSE Client connected: #<StringIO:0x007f882b4c2420>
577
+ Starting SSE heartbeat thread!
578
+ New SSE Client connected: #<StringIO:0x007f882b4b9fa0>
579
+ Starting SSE heartbeat thread!
580
+ Starting SSE heartbeat thread!
581
+ New SSE Client connected: #<StringIO:0x007f882b4b0cc0>
582
+ Starting SSE heartbeat thread!
583
+ New SSE Client connected: #<StringIO:0x007f882b4a3250>
584
+ SSE Client disconnected: #<StringIO:0x007f882b4a3250> - IOError
585
+ Starting SSE heartbeat thread!
586
+ New SSE Client connected: #<StringIO:0x007f882b4a0550>
587
+ Starting SSE heartbeat thread!
588
+ Starting SSE heartbeat thread!
589
+ New SSE Client connected: #<StringIO:0x007f882b48b880>
590
+ Starting SSE heartbeat thread!
591
+ New SSE Client connected: #<StringIO:0x007f882b488630>
592
+ Starting SSE heartbeat thread!
593
+ Starting SSE heartbeat thread!
594
+ New SSE Client connected: #<StringIO:0x007fb5342ab728> - ["foo", "bar"]
595
+ Starting SSE heartbeat thread!
596
+ Starting SSE heartbeat thread!
597
+ New SSE Client connected: #<StringIO:0x007fb5342a1390> - []
598
+ Starting SSE heartbeat thread!
599
+ New SSE Client connected: #<StringIO:0x007fb534293c68> - []
600
+ Starting SSE heartbeat thread!
601
+ Starting SSE heartbeat thread!
602
+ New SSE Client connected: #<StringIO:0x007fb53428b1a8> - ["foo", "bar"]
603
+ Starting SSE heartbeat thread!
604
+ New SSE Client connected: #<StringIO:0x007fb534280d20> - []
605
+ SSE Client disconnected: #<StringIO:0x007fb534280d20> - IOError
606
+ Starting SSE heartbeat thread!
607
+ New SSE Client connected: #<StringIO:0x007fb534273aa8> - []
608
+ SSE Client disconnected: #<StringIO:0x007fb534273aa8> - IOError
609
+ Starting SSE heartbeat thread!
610
+ New SSE Client connected: #<StringIO:0x007fb534270830> - []
611
+ Starting SSE heartbeat thread!
612
+ Starting SSE heartbeat thread!
613
+ New SSE Client connected: #<StringIO:0x007fb534260098> - []
614
+ Starting SSE heartbeat thread!
615
+ New SSE Client connected: #<StringIO:0x007fb534253258> - []
616
+ New SSE Client connected: #<StringIO:0x007fb534253730> - ["foo", "bar"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sse-rails-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Hender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-16 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails