message_bus 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG +4 -0
- data/README.md +1 -1
- data/assets/message-bus.js +3 -3
- data/lib/message_bus/rack/middleware.rb +13 -0
- data/lib/message_bus/rails/railtie.rb +8 -1
- data/lib/message_bus/version.rb +1 -1
- data/message_bus.gemspec +2 -1
- data/spec/lib/assets/asset_encoding_spec.rb +19 -0
- data/spec/spec_helper.rb +0 -4
- data/vendor/assets/javascripts/message-bus.js +3 -3
- metadata +18 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f276c95da4b72d4c4ed5710fd1af3883116ee77a
|
|
4
|
+
data.tar.gz: ace4ed261e91e1efa464c4a30eec2ffed0a05291
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe593ca357284143f1ab125a4dea02eb8060414830f8b613e2cabca8bbbdfb4746c9a9df83529d318bf233b00bc84d297d191e0185dbd4782d1cf7388e40cf8b
|
|
7
|
+
data.tar.gz: 0af4fe02cd3479d72285b6e3b7d6f937279c6defc02a4bcf0603a2e832ee240da78e12c4d8ccf08fa5ff54a7e0799dda5d6a72ea9a18829e4ca82b8e6611016f
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
data/assets/message-bus.js
CHANGED
|
@@ -60,8 +60,8 @@ window.MessageBus = (function() {
|
|
|
60
60
|
|
|
61
61
|
var toElement = originalEvent.toElement;
|
|
62
62
|
|
|
63
|
-
// If it
|
|
64
|
-
// should both be `null` or `undefined`; else, the page visibility hasn
|
|
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
|
-
|
|
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
|
data/lib/message_bus/version.rb
CHANGED
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
|
@@ -60,8 +60,8 @@ window.MessageBus = (function() {
|
|
|
60
60
|
|
|
61
61
|
var toElement = originalEvent.toElement;
|
|
62
62
|
|
|
63
|
-
// If it
|
|
64
|
-
// should both be `null` or `undefined`; else, the page visibility hasn
|
|
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
|
+
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-
|
|
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.
|
|
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
|