message_bus 3.3.4 → 3.3.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 +4 -4
- data/.github/workflows/ci.yml +54 -0
- data/.rubocop.yml +3 -1
- data/CHANGELOG +8 -1
- data/DEV.md +9 -0
- data/README.md +0 -6
- data/assets/message-bus-ajax.js +1 -7
- data/assets/message-bus.js +1 -23
- data/lib/message_bus/rack/middleware.rb +16 -16
- data/lib/message_bus/version.rb +1 -1
- data/message_bus.gemspec +1 -1
- data/package.json +1 -1
- metadata +9 -8
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f34126c192c671b895e7cf912a04ffcb5d05a5a5447786c3f5e3db3595c79004
|
4
|
+
data.tar.gz: 5a638bf3eb07680d17d93b762bc41d92d8b4c4412d9f3fae3e7410ec2ae67488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7102c7e62cc9854237fab235e2020f318bbdc956ba64f6d0c77c515430df1169bb06e01a9125f71631546daa3dfa1179c971ca207f32a9cda96880b0d9be6c6
|
7
|
+
data.tar.gz: 91b8e655e1dc27b4f386477d38dea8ef4f44daa658793a2205392135cb2f846a80ac0aca52fc04c9a471990b64cb18c6ea9dbd36818690c28cac0c80f922d8be
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Message Bus Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
env:
|
10
|
+
PGHOST: localhost
|
11
|
+
PGPORT: 5432
|
12
|
+
PGPASSWORD: postgres
|
13
|
+
PGUSER: postgres
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
build:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
name: Ruby ${{ matrix.ruby }}
|
19
|
+
services:
|
20
|
+
postgres:
|
21
|
+
image: postgres:9.4
|
22
|
+
env:
|
23
|
+
POSTGRES_PASSWORD: postgres
|
24
|
+
ports:
|
25
|
+
- 5432:5432
|
26
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
27
|
+
strategy:
|
28
|
+
matrix:
|
29
|
+
ruby: ["2.7", "2.6", "2.5"]
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
- uses: actions/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
- name: Bundler cache
|
36
|
+
uses: actions/cache@v2
|
37
|
+
with:
|
38
|
+
path: vendor/bundle
|
39
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
40
|
+
restore-keys: |
|
41
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-
|
42
|
+
- name: Create Database
|
43
|
+
run: |
|
44
|
+
createdb message_bus_test
|
45
|
+
- name: Setup redis
|
46
|
+
uses: shogo82148/actions-setup-redis@v1
|
47
|
+
with:
|
48
|
+
redis-version: '5.x'
|
49
|
+
- name: Setup gems
|
50
|
+
run: |
|
51
|
+
bundle config path vendor/bundle
|
52
|
+
bundle install --jobs 4
|
53
|
+
- name: Tests
|
54
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
-
|
1
|
+
28-04-2021
|
2
|
+
|
3
|
+
- Version 3.3.5
|
4
|
+
|
5
|
+
- PERF: Optimised CORS preflight handling
|
6
|
+
- FEATURE: Enable CORS preflight caching
|
7
|
+
- FEATURE: Removed trailing cache buster from message bus polls
|
8
|
+
- PERF: Improved delay poll timeout for cases where a tab moves in and out of the background
|
2
9
|
|
3
10
|
02-10-2020
|
4
11
|
|
data/DEV.md
ADDED
data/README.md
CHANGED
@@ -10,12 +10,6 @@ MessageBus is implemented as Rack middleware and can be used by any Rails / Sina
|
|
10
10
|
|
11
11
|
Read the generated docs: <https://www.rubydoc.info/gems/message_bus>
|
12
12
|
|
13
|
-
## Try it out!
|
14
|
-
|
15
|
-
Live chat demo per [examples/chat](https://github.com/SamSaffron/message_bus/tree/master/examples/chat) is at:
|
16
|
-
|
17
|
-
### http://chat.samsaffron.com
|
18
|
-
|
19
13
|
## Ruby version support
|
20
14
|
|
21
15
|
MessageBus only support officially supported versions of Ruby; as of [2018-06-20](https://www.ruby-lang.org/en/news/2018/06/20/support-of-ruby-2-2-has-ended/) this means we only support Ruby version 2.3 and up.
|
data/assets/message-bus-ajax.js
CHANGED
@@ -8,17 +8,11 @@
|
|
8
8
|
throw new Error("MessageBus must be loaded before the ajax adapter");
|
9
9
|
}
|
10
10
|
|
11
|
-
var cacheBuster = Math.random() * 10000 | 0;
|
12
|
-
|
13
11
|
global.MessageBus.ajax = function(options){
|
14
12
|
var XHRImpl = (global.MessageBus && global.MessageBus.xhrImplementation) || global.XMLHttpRequest;
|
15
13
|
var xhr = new XHRImpl();
|
16
14
|
xhr.dataType = options.dataType;
|
17
|
-
|
18
|
-
if (!options.cache){
|
19
|
-
url += ((-1 == url.indexOf('?')) ? '?' : '&') + '_=' + (cacheBuster++)
|
20
|
-
}
|
21
|
-
xhr.open('POST', url);
|
15
|
+
xhr.open('POST', options.url);
|
22
16
|
for (var name in options.headers){
|
23
17
|
xhr.setRequestHeader(name, options.headers[name]);
|
24
18
|
}
|
data/assets/message-bus.js
CHANGED
@@ -31,8 +31,6 @@
|
|
31
31
|
var started = false;
|
32
32
|
var clientId = uniqueId();
|
33
33
|
var callbacks = [];
|
34
|
-
var queue = [];
|
35
|
-
var interval = null;
|
36
34
|
var failCount = 0;
|
37
35
|
var baseUrl = "/";
|
38
36
|
var paused = false;
|
@@ -103,7 +101,6 @@
|
|
103
101
|
};
|
104
102
|
|
105
103
|
var processMessages = function(messages) {
|
106
|
-
var gotData = false;
|
107
104
|
if ((!messages) || (messages.length === 0)) { return false; }
|
108
105
|
|
109
106
|
for (var i = 0; i < messages.length; i++) {
|
@@ -213,24 +210,6 @@
|
|
213
210
|
}
|
214
211
|
};
|
215
212
|
|
216
|
-
var setOnProgressListener = function(xhr) {
|
217
|
-
var position = 0;
|
218
|
-
// if it takes longer than 3000 ms to get first chunk, we have some proxy
|
219
|
-
// this is messing with us, so just backoff from using chunked for now
|
220
|
-
var chunkedTimeout = setTimeout(disableChunked, 3000);
|
221
|
-
xhr.onprogress = function() {
|
222
|
-
clearTimeout(chunkedTimeout);
|
223
|
-
if (
|
224
|
-
xhr.getResponseHeader("Content-Type") ===
|
225
|
-
"application/json; charset=utf-8"
|
226
|
-
) {
|
227
|
-
// not chunked we are sending json back
|
228
|
-
chunked = false;
|
229
|
-
return;
|
230
|
-
}
|
231
|
-
position = handle_progress(xhr.responseText, position);
|
232
|
-
};
|
233
|
-
};
|
234
213
|
if (!me.ajax) {
|
235
214
|
throw new Error("Either jQuery or the ajax adapter must be loaded");
|
236
215
|
}
|
@@ -246,7 +225,6 @@
|
|
246
225
|
"/poll" +
|
247
226
|
(!longPoll ? "?dlp=t" : ""),
|
248
227
|
data: data,
|
249
|
-
cache: false,
|
250
228
|
async: true,
|
251
229
|
dataType: dataType,
|
252
230
|
type: "POST",
|
@@ -451,7 +429,7 @@
|
|
451
429
|
me.visibilityEvent = document.addEventListener(
|
452
430
|
"visibilitychange",
|
453
431
|
function() {
|
454
|
-
if (!document.hidden && !me.longPoll && pollTimeout) {
|
432
|
+
if (!document.hidden && !me.longPoll && (pollTimeout || delayPollTimeout)) {
|
455
433
|
clearTimeout(pollTimeout);
|
456
434
|
clearTimeout(delayPollTimeout);
|
457
435
|
|
@@ -81,6 +81,22 @@ class MessageBus::Rack::Middleware
|
|
81
81
|
client_id = env['PATH_INFO'][@base_route_length..-1].split("/")[0]
|
82
82
|
return [404, {}, ["not found"]] unless client_id
|
83
83
|
|
84
|
+
headers = {}
|
85
|
+
headers["Cache-Control"] = "must-revalidate, private, max-age=0"
|
86
|
+
headers["Content-Type"] = "application/json; charset=utf-8"
|
87
|
+
headers["Pragma"] = "no-cache"
|
88
|
+
headers["Expires"] = "0"
|
89
|
+
|
90
|
+
if @bus.extra_response_headers_lookup
|
91
|
+
@bus.extra_response_headers_lookup.call(env).each do |k, v|
|
92
|
+
headers[k] = v
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
if env["REQUEST_METHOD"] == "OPTIONS"
|
97
|
+
return [200, headers, ["OK"]]
|
98
|
+
end
|
99
|
+
|
84
100
|
user_id = @bus.user_id_lookup.call(env) if @bus.user_id_lookup
|
85
101
|
group_ids = @bus.group_ids_lookup.call(env) if @bus.group_ids_lookup
|
86
102
|
site_id = @bus.site_id_lookup.call(env) if @bus.site_id_lookup
|
@@ -111,22 +127,6 @@ class MessageBus::Rack::Middleware
|
|
111
127
|
end
|
112
128
|
end
|
113
129
|
|
114
|
-
headers = {}
|
115
|
-
headers["Cache-Control"] = "must-revalidate, private, max-age=0"
|
116
|
-
headers["Content-Type"] = "application/json; charset=utf-8"
|
117
|
-
headers["Pragma"] = "no-cache"
|
118
|
-
headers["Expires"] = "0"
|
119
|
-
|
120
|
-
if @bus.extra_response_headers_lookup
|
121
|
-
@bus.extra_response_headers_lookup.call(env).each do |k, v|
|
122
|
-
headers[k] = v
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
if env["REQUEST_METHOD"] == "OPTIONS"
|
127
|
-
return [200, headers, ["OK"]]
|
128
|
-
end
|
129
|
-
|
130
130
|
long_polling = @bus.long_polling_enabled? &&
|
131
131
|
env['QUERY_STRING'] !~ /dlp=t/ &&
|
132
132
|
@connection_manager.client_count < @bus.max_active_clients
|
data/lib/message_bus/version.rb
CHANGED
data/message_bus.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.name = "message_bus"
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
gem.version = MessageBus::VERSION
|
20
|
-
gem.required_ruby_version = ">= 2.
|
20
|
+
gem.required_ruby_version = ">= 2.4.0"
|
21
21
|
gem.add_runtime_dependency 'rack', '>= 1.1.3'
|
22
22
|
gem.add_development_dependency 'redis'
|
23
23
|
gem.add_development_dependency 'pg'
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -59,10 +59,11 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/ci.yml"
|
62
63
|
- ".gitignore"
|
63
64
|
- ".rubocop.yml"
|
64
|
-
- ".travis.yml"
|
65
65
|
- CHANGELOG
|
66
|
+
- DEV.md
|
66
67
|
- Dockerfile
|
67
68
|
- Gemfile
|
68
69
|
- Guardfile
|
@@ -141,7 +142,7 @@ homepage: https://github.com/SamSaffron/message_bus
|
|
141
142
|
licenses:
|
142
143
|
- MIT
|
143
144
|
metadata: {}
|
144
|
-
post_install_message:
|
145
|
+
post_install_message:
|
145
146
|
rdoc_options: []
|
146
147
|
require_paths:
|
147
148
|
- lib
|
@@ -149,15 +150,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
150
|
requirements:
|
150
151
|
- - ">="
|
151
152
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.
|
153
|
+
version: 2.4.0
|
153
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
155
|
requirements:
|
155
156
|
- - ">="
|
156
157
|
- !ruby/object:Gem::Version
|
157
158
|
version: '0'
|
158
159
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
160
|
+
rubygems_version: 3.2.2
|
161
|
+
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: ''
|
163
164
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
before_install: gem install bundler
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.5
|
5
|
-
- 2.6
|
6
|
-
- 2.7
|
7
|
-
gemfile:
|
8
|
-
- Gemfile
|
9
|
-
addons:
|
10
|
-
postgresql: "9.4"
|
11
|
-
env:
|
12
|
-
- PGUSER=postgres
|
13
|
-
before_script:
|
14
|
-
- psql -c 'create database message_bus_test;' -U postgres
|
15
|
-
services:
|
16
|
-
- redis-server
|
17
|
-
- postgresql
|