message_bus 0.9.4 → 0.9.5

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
  SHA1:
3
- metadata.gz: bd00357fe6b7e4663c46c3c34c74a5d8529433c5
4
- data.tar.gz: df3641a9d63749c6035ecd0b45d656bd53361e4d
3
+ metadata.gz: f276c95da4b72d4c4ed5710fd1af3883116ee77a
4
+ data.tar.gz: ace4ed261e91e1efa464c4a30eec2ffed0a05291
5
5
  SHA512:
6
- metadata.gz: c08c802702acc7c30db0c3ebfb1c0949644553b7fc6a63330a8f260d414a350e94c2fb40143bd3956a068eda1a8e764e3fc3f858568bedb5075d25d82392185d
7
- data.tar.gz: 41c4d7584df49be995a21495841d63d65998aab5582c5ec6987fc620f86b995cc632e505fa641558c15568d8e6545075d075f4eec1c6501ad21fc4563220dc99
6
+ metadata.gz: fe593ca357284143f1ab125a4dea02eb8060414830f8b613e2cabca8bbbdfb4746c9a9df83529d318bf233b00bc84d297d191e0185dbd4782d1cf7388e40cf8b
7
+ data.tar.gz: 0af4fe02cd3479d72285b6e3b7d6f937279c6defc02a4bcf0603a2e832ee240da78e12c4d8ccf08fa5ff54a7e0799dda5d6a72ea9a18829e4ca82b8e6611016f
data/.travis.yml CHANGED
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.2
5
6
  gemfile:
6
7
  - Gemfile
7
8
  services:
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 11-08-2014
2
+ - Version 0.9.5
3
+ - Fix: release db connection a lot earlier for long polling (rails defer closes)
4
+
1
5
  13-01-2014
2
6
  - Version 0.9.4
3
7
  - Added support for /global/ channel to publish messages across a multisite
data/README.md CHANGED
@@ -91,7 +91,7 @@ MessageBus.start(); // call once at startup
91
91
  MessageBus.callbackInterval = 500;
92
92
  MessageBus.subscribe("/channel", function(data){
93
93
  // data shipped from server
94
- }
94
+ });
95
95
 
96
96
 
97
97
  ```
@@ -60,8 +60,8 @@ window.MessageBus = (function() {
60
60
 
61
61
  var toElement = originalEvent.toElement;
62
62
 
63
- // If its a `{focusin,focusout}` event (IE), `fromElement` and `toElement`
64
- // should both be `null` or `undefined`; else, the page visibility hasnt
63
+ // If it's a `{focusin,focusout}` event (IE), `fromElement` and `toElement`
64
+ // should both be `null` or `undefined`; else, the page visibility hasn't
65
65
  // changed, but the user just clicked somewhere in the doc. In IE9, we need
66
66
  // to check the `relatedTarget` property instead.
67
67
  if (
@@ -109,7 +109,7 @@ window.MessageBus = (function() {
109
109
  lastAjax = new Date();
110
110
  totalAjaxCalls += 1;
111
111
 
112
- return $.ajax(baseUrl + "message-bus/" + clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
112
+ return $.ajax(me.baseUrl + "message-bus/" + me.clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
113
113
  data: data,
114
114
  cache: false,
115
115
  dataType: 'json',
@@ -73,6 +73,9 @@ class MessageBus::Rack::Middleware
73
73
  group_ids = @bus.group_ids_lookup.call(env) if @bus.group_ids_lookup
74
74
  site_id = @bus.site_id_lookup.call(env) if @bus.site_id_lookup
75
75
 
76
+ # close db connection as early as possible
77
+ close_db_connection!
78
+
76
79
  client = MessageBus::Client.new(message_bus: @bus, client_id: client_id, user_id: user_id, site_id: site_id, group_ids: group_ids)
77
80
 
78
81
  request = Rack::Request.new(env)
@@ -124,6 +127,16 @@ class MessageBus::Rack::Middleware
124
127
  end
125
128
  end
126
129
 
130
+ def close_db_connection!
131
+ # IMPORTANT
132
+ # ConnectionManagement in Rails puts a BodyProxy around stuff
133
+ # this means connections are not returned until rack.async is
134
+ # closed
135
+ if defined? ActiveRecord::Base.clear_active_connections!
136
+ ActiveRecord::Base.clear_active_connections!
137
+ end
138
+ end
139
+
127
140
  def ensure_reactor
128
141
  # ensure reactor is running
129
142
  if EM.reactor_pid != Process.pid
@@ -6,7 +6,14 @@ class MessageBus::Rails::Engine < ::Rails::Engine; end
6
6
  class MessageBus::Rails::Railtie < ::Rails::Railtie
7
7
  initializer "message_bus.configure_init" do |app|
8
8
  MessageBus::MessageHandler.load_handlers("#{Rails.root}/app/message_handlers")
9
- app.middleware.insert_after(ActiveRecord::QueryCache, MessageBus::Rack::Middleware)
9
+
10
+ # We want MessageBus to show up after the session middleware, but depending on how
11
+ # the Rails app is configured that might be ActionDispatch::Session::CookieStore, or potentially
12
+ # ActionDispatch::Session::ActiveRecordStore.
13
+ #
14
+ # To handle either case, we insert it before ActionDispatch::Flash.
15
+ #
16
+ app.middleware.insert_before(ActionDispatch::Flash, MessageBus::Rack::Middleware)
10
17
  MessageBus.logger = Rails.logger
11
18
  end
12
19
  end
@@ -1,3 +1,3 @@
1
1
  module MessageBus
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
data/message_bus.gemspec CHANGED
@@ -6,7 +6,8 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["sam.saffron@gmail.com"]
7
7
  gem.description = %q{A message bus for rack}
8
8
  gem.summary = %q{}
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/SamSaffron/message_bus"
10
+ gem.license = "MIT"
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -0,0 +1,19 @@
1
+ asset_directory = File.expand_path('../../../../assets', __FILE__)
2
+ asset_file_paths = Dir.glob(File.join(asset_directory, 'message-bus.js'))
3
+ asset_file_names = asset_file_paths.map{|e| File.basename(e) }
4
+
5
+ describe asset_file_names do
6
+ it 'should contain .js files' do
7
+ expect(asset_file_names).to include('message-bus.js')
8
+ end
9
+ end
10
+
11
+ asset_file_paths.each do | path |
12
+ describe "Asset file #{File.basename(path).inspect}" do
13
+ it 'should be encodable as UTF8' do
14
+ binary_data = File.open(path, 'rb'){|f| f.read }
15
+ encode_block = -> { binary_data.encode(Encoding::UTF_8) }
16
+ expect(encode_block).not_to raise_error
17
+ end
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  require 'thin'
2
2
  require 'lib/fake_async_middleware'
3
3
 
4
- RSpec.configure do |config|
5
- config.color_enabled = true
6
- end
7
-
8
4
  def wait_for(timeout_milliseconds)
9
5
  timeout = (timeout_milliseconds + 0.0) / 1000
10
6
  finish = Time.now + timeout
@@ -60,8 +60,8 @@ window.MessageBus = (function() {
60
60
 
61
61
  var toElement = originalEvent.toElement;
62
62
 
63
- // If its a `{focusin,focusout}` event (IE), `fromElement` and `toElement`
64
- // should both be `null` or `undefined`; else, the page visibility hasnt
63
+ // If it's a `{focusin,focusout}` event (IE), `fromElement` and `toElement`
64
+ // should both be `null` or `undefined`; else, the page visibility hasn't
65
65
  // changed, but the user just clicked somewhere in the doc. In IE9, we need
66
66
  // to check the `relatedTarget` property instead.
67
67
  if (
@@ -109,7 +109,7 @@ window.MessageBus = (function() {
109
109
  lastAjax = new Date();
110
110
  totalAjaxCalls += 1;
111
111
 
112
- return $.ajax(baseUrl + "message-bus/" + clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
112
+ return $.ajax(me.baseUrl + "message-bus/" + me.clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
113
113
  data: data,
114
114
  cache: false,
115
115
  dataType: 'json',
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-14 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eventmachine
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: redis
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: A message bus for rack
@@ -59,8 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
64
  - CHANGELOG
65
65
  - Gemfile
66
66
  - Guardfile
@@ -96,6 +96,7 @@ files:
96
96
  - lib/message_bus/reliable_pub_sub.rb
97
97
  - lib/message_bus/version.rb
98
98
  - message_bus.gemspec
99
+ - spec/lib/assets/asset_encoding_spec.rb
99
100
  - spec/lib/client_spec.rb
100
101
  - spec/lib/connection_manager_spec.rb
101
102
  - spec/lib/fake_async_middleware.rb
@@ -107,8 +108,9 @@ files:
107
108
  - spec/lib/reliable_pub_sub_spec.rb
108
109
  - spec/spec_helper.rb
109
110
  - vendor/assets/javascripts/message-bus.js
110
- homepage: ''
111
- licenses: []
111
+ homepage: https://github.com/SamSaffron/message_bus
112
+ licenses:
113
+ - MIT
112
114
  metadata: {}
113
115
  post_install_message:
114
116
  rdoc_options: []
@@ -116,21 +118,22 @@ require_paths:
116
118
  - lib
117
119
  required_ruby_version: !ruby/object:Gem::Requirement
118
120
  requirements:
119
- - - '>='
121
+ - - ">="
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  requirements:
124
- - - '>='
126
+ - - ">="
125
127
  - !ruby/object:Gem::Version
126
128
  version: '0'
127
129
  requirements: []
128
130
  rubyforge_project:
129
- rubygems_version: 2.0.14
131
+ rubygems_version: 2.2.2
130
132
  signing_key:
131
133
  specification_version: 4
132
134
  summary: ''
133
135
  test_files:
136
+ - spec/lib/assets/asset_encoding_spec.rb
134
137
  - spec/lib/client_spec.rb
135
138
  - spec/lib/connection_manager_spec.rb
136
139
  - spec/lib/fake_async_middleware.rb