message_bus 3.3.4 → 3.3.8
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/.eslintrc.js +21 -0
- data/.github/workflows/ci.yml +99 -0
- data/.gitignore +2 -0
- data/.prettierrc +1 -0
- data/.rubocop.yml +3 -1
- data/CHANGELOG +30 -8
- data/DEV.md +7 -0
- data/Gemfile +0 -25
- data/LICENSE +1 -1
- data/README.md +34 -15
- data/Rakefile +13 -8
- data/assets/message-bus-ajax.js +4 -10
- data/assets/message-bus.js +69 -76
- data/bench/codecs/all_codecs.rb +39 -0
- data/bench/codecs/marshal.rb +11 -0
- data/bench/codecs/packed_string.rb +67 -0
- data/bench/codecs/string_hack.rb +47 -0
- data/bench/codecs_large_user_list.rb +29 -0
- data/bench/codecs_standard_message.rb +29 -0
- data/examples/bench/bench.lua +2 -2
- data/lib/message_bus/backends/base.rb +8 -5
- data/lib/message_bus/backends/memory.rb +6 -2
- data/lib/message_bus/backends/postgres.rb +27 -18
- data/lib/message_bus/backends/redis.rb +9 -6
- data/lib/message_bus/client.rb +6 -7
- data/lib/message_bus/codec/base.rb +18 -0
- data/lib/message_bus/codec/json.rb +15 -0
- data/lib/message_bus/codec/oj.rb +21 -0
- data/lib/message_bus/connection_manager.rb +1 -1
- data/lib/message_bus/distributed_cache.rb +3 -1
- data/lib/message_bus/http_client.rb +2 -2
- data/lib/message_bus/rack/diagnostics.rb +30 -8
- data/lib/message_bus/rack/middleware.rb +22 -16
- data/lib/message_bus/rack/thin_ext.rb +2 -1
- data/lib/message_bus/version.rb +1 -1
- data/lib/message_bus.rb +42 -22
- data/message_bus.gemspec +21 -3
- data/package-lock.json +3744 -0
- data/package.json +15 -8
- data/spec/assets/SpecHelper.js +6 -5
- data/spec/assets/message-bus.spec.js +9 -6
- data/spec/helpers.rb +23 -7
- data/spec/integration/http_client_spec.rb +1 -1
- data/spec/lib/fake_async_middleware.rb +1 -0
- data/spec/lib/message_bus/backend_spec.rb +13 -44
- data/spec/lib/message_bus/client_spec.rb +7 -6
- data/spec/lib/message_bus/connection_manager_spec.rb +4 -0
- data/spec/lib/message_bus/distributed_cache_spec.rb +5 -7
- data/spec/lib/message_bus/multi_process_spec.rb +19 -9
- data/spec/lib/message_bus/rack/middleware_spec.rb +18 -6
- data/spec/lib/message_bus_spec.rb +13 -8
- data/spec/spec_helper.rb +8 -9
- data/spec/support/jasmine-browser.json +16 -0
- data/vendor/assets/javascripts/message-bus-ajax.js +4 -10
- data/vendor/assets/javascripts/message-bus.js +69 -76
- metadata +231 -11
- data/.travis.yml +0 -17
- data/lib/message_bus/em_ext.rb +0 -6
- data/spec/assets/support/jasmine.yml +0 -126
- data/spec/assets/support/jasmine_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b45c0d65f5a82c9465f620059d2125ebca09ee5619a9094fcbc309a0e179a983
|
4
|
+
data.tar.gz: b691c40ae2360ae661aa83f83e9647cb0223a70a6ca536f285db21ce791a3ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb5db140d0fc8bbee5df6e00f57560b1e399c7cac86d825f9841c4c9d8bc805ec8f9ab2ea8ba0ad066c53039a44b5044ecef7299a74f942b3a52cd426ecbef6
|
7
|
+
data.tar.gz: 66fdc2a3c483d1b775b3963b71bdc422edcdf16233cb47aa2ec99d3a6946e6e0f6f6ca917db12e5d528de6dfb39cc494923e2abe380ca0c75d64d92f6f167d7e
|
data/.eslintrc.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
/*global module*/
|
2
|
+
module.exports = {
|
3
|
+
env: {
|
4
|
+
browser: true,
|
5
|
+
es2021: false,
|
6
|
+
},
|
7
|
+
extends: 'eslint:recommended',
|
8
|
+
parserOptions: {
|
9
|
+
ecmaVersion: 2015,
|
10
|
+
sourceType: 'module',
|
11
|
+
},
|
12
|
+
rules: {},
|
13
|
+
ignorePatterns: [
|
14
|
+
'/vendor',
|
15
|
+
'/doc',
|
16
|
+
'/assets/babel.min.js',
|
17
|
+
'/assets/jquery-1.8.2.js',
|
18
|
+
'/assets/react-dom.js',
|
19
|
+
'/assets/react.js',
|
20
|
+
],
|
21
|
+
};
|
@@ -0,0 +1,99 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
name: Ruby ${{ matrix.ruby }} (redis ${{ matrix.redis }})
|
13
|
+
timeout-minutes: 10
|
14
|
+
|
15
|
+
env:
|
16
|
+
PGHOST: localhost
|
17
|
+
PGPASSWORD: postgres
|
18
|
+
PGUSER: postgres
|
19
|
+
|
20
|
+
strategy:
|
21
|
+
fail-fast: false
|
22
|
+
matrix:
|
23
|
+
ruby: [2.6, 2.7, 3.0]
|
24
|
+
redis: [5, 6]
|
25
|
+
|
26
|
+
services:
|
27
|
+
postgres:
|
28
|
+
image: postgres:14
|
29
|
+
env:
|
30
|
+
POSTGRES_DB: message_bus_test
|
31
|
+
POSTGRES_PASSWORD: postgres
|
32
|
+
ports:
|
33
|
+
- 5432:5432
|
34
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
35
|
+
redis:
|
36
|
+
image: ${{ format('redis:{0}', matrix.redis) }}
|
37
|
+
ports:
|
38
|
+
- 6379:6379
|
39
|
+
options: >-
|
40
|
+
--health-cmd "redis-cli ping"
|
41
|
+
--health-interval 10s
|
42
|
+
--health-timeout 5s
|
43
|
+
--health-retries 5
|
44
|
+
|
45
|
+
steps:
|
46
|
+
- uses: actions/checkout@v2
|
47
|
+
|
48
|
+
- uses: ruby/setup-ruby@v1
|
49
|
+
with:
|
50
|
+
ruby-version: ${{ matrix.ruby }}
|
51
|
+
bundler-cache: true
|
52
|
+
|
53
|
+
- name: Set up Node.js
|
54
|
+
uses: actions/setup-node@v2
|
55
|
+
with:
|
56
|
+
node-version: 16
|
57
|
+
cache: npm
|
58
|
+
|
59
|
+
- name: Setup npm
|
60
|
+
run: npm install
|
61
|
+
|
62
|
+
- name: Tests
|
63
|
+
run: bundle exec rake
|
64
|
+
timeout-minutes: 3
|
65
|
+
|
66
|
+
- name: Linting
|
67
|
+
run: npx eslint .
|
68
|
+
|
69
|
+
publish:
|
70
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
71
|
+
needs: build
|
72
|
+
runs-on: ubuntu-latest
|
73
|
+
|
74
|
+
steps:
|
75
|
+
- uses: actions/checkout@v2
|
76
|
+
|
77
|
+
- name: Release gem
|
78
|
+
uses: discourse/publish-rubygems-action@v2
|
79
|
+
id: publish-gem
|
80
|
+
env:
|
81
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
82
|
+
GIT_EMAIL: team@discourse.org
|
83
|
+
GIT_NAME: discoursebot
|
84
|
+
|
85
|
+
- name: Update package version
|
86
|
+
if: steps.publish-gem.outputs.new_version == 'true'
|
87
|
+
run: |
|
88
|
+
VERSION=$(ruby -r './lib/message_bus/version' -e 'puts MessageBus::VERSION')
|
89
|
+
sed -i "s/0.0.0-version-placeholder/$VERSION/" package.json
|
90
|
+
git config --global user.email "ci@ci.invalid"
|
91
|
+
git config --global user.name "Discourse CI"
|
92
|
+
git add package.json
|
93
|
+
git commit -m 'bump'
|
94
|
+
|
95
|
+
- name: Publish package
|
96
|
+
uses: JS-DevTools/npm-publish@v1
|
97
|
+
if: steps.publish-gem.outputs.new_version == 'true'
|
98
|
+
with:
|
99
|
+
token: ${{ secrets.NPM_TOKEN }}
|
data/.gitignore
CHANGED
data/.prettierrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
data/.rubocop.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,4 +1,26 @@
|
|
1
|
-
-
|
1
|
+
15-12-2021
|
2
|
+
|
3
|
+
- Version 3.3.7
|
4
|
+
|
5
|
+
- FIX: Prevent simple polling from clobbering the session
|
6
|
+
- SECURITY: Fix path traversal on diagnostics route.
|
7
|
+
|
8
|
+
31-05-2021
|
9
|
+
|
10
|
+
- Version 3.3.6
|
11
|
+
|
12
|
+
- FEATURE: Introduce support for transport codecs
|
13
|
+
- FIX: event subscription leak in JS after start/stop/start sequence
|
14
|
+
- FEATURE: MessageBus.onVisibilityChange() can be used to trigger a visibility change check by hand
|
15
|
+
|
16
|
+
28-04-2021
|
17
|
+
|
18
|
+
- Version 3.3.5
|
19
|
+
|
20
|
+
- PERF: Optimised CORS preflight handling
|
21
|
+
- FEATURE: Enable CORS preflight caching
|
22
|
+
- FEATURE: Removed trailing cache buster from message bus polls
|
23
|
+
- PERF: Improved delay poll timeout for cases where a tab moves in and out of the background
|
2
24
|
|
3
25
|
02-10-2020
|
4
26
|
|
@@ -47,7 +69,7 @@
|
|
47
69
|
|
48
70
|
- Version 3.2.0
|
49
71
|
|
50
|
-
- FIX:
|
72
|
+
- FIX: compatibility with Rails 6.0.3, note: apps without ActionDispatch::Flash may stop working after this upgrade
|
51
73
|
to correct this disable middleware injection with `config.skip_message_bus_middleware = true` and configure middleware by hand with `app.middleware.use(MessageBus::Rack::Middleware)`
|
52
74
|
|
53
75
|
28-04-2020
|
@@ -174,7 +196,7 @@
|
|
174
196
|
|
175
197
|
- Version 2.1.6
|
176
198
|
|
177
|
-
- FEATURE: `
|
199
|
+
- FEATURE: `MessageBus.publish` accepts option `site_id` to publish to a site
|
178
200
|
- FEATURE: Added MessageBus::DistributedCache for cross process caching
|
179
201
|
- PERF: Use monotonic times in timer thread
|
180
202
|
- FEATURE: min poll interval is now configurable client side
|
@@ -238,7 +260,7 @@
|
|
238
260
|
|
239
261
|
- Version 2.0.6
|
240
262
|
|
241
|
-
- Fix: correct after_fork so it correctly
|
263
|
+
- Fix: correct after_fork so it correctly disconnects redis
|
242
264
|
- Fix: correct message_bus #destroy used in tests to clean up spec (deadlock)
|
243
265
|
- Fix: deliver backlog unconditionally when polling (and not long polling)
|
244
266
|
|
@@ -308,7 +330,7 @@
|
|
308
330
|
|
309
331
|
- Version 2.0.0.beta.6
|
310
332
|
|
311
|
-
- Feature: Support standalone
|
333
|
+
- Feature: Support standalone operation without depending on jQuery @nathanstitt
|
312
334
|
- Feature: Support a noconflict mode @nathanstitt
|
313
335
|
- Feature: Support JSON POST payload @nathanstitt
|
314
336
|
|
@@ -354,7 +376,7 @@
|
|
354
376
|
- Version 1.1.0
|
355
377
|
- Fix: keep track of client sequence on server, abandon old subscribes
|
356
378
|
- Fix: rare concurrency issue when subscribing concurrently
|
357
|
-
-
|
379
|
+
- Feature: remove most jQuery dependency from message-bus.js
|
358
380
|
|
359
381
|
09-07-2015
|
360
382
|
- Version 1.0.16
|
@@ -378,7 +400,7 @@
|
|
378
400
|
|
379
401
|
28-05-2015
|
380
402
|
- Version 1.0.12
|
381
|
-
- Feature: Support client_id
|
403
|
+
- Feature: Support client_id targeted message
|
382
404
|
|
383
405
|
06-05-2015
|
384
406
|
- Version 1.0.11
|
@@ -387,7 +409,7 @@
|
|
387
409
|
01-05-2015
|
388
410
|
- Version: 1.0.10
|
389
411
|
- Feature: no longer depends on EventMachine (only used for Thin backend)
|
390
|
-
- Feature:
|
412
|
+
- Feature: reliable pub sub will queue messages in memory if redis is readonly, configurable
|
391
413
|
- Fix: if redis is flushed we will continue to deliver messages
|
392
414
|
|
393
415
|
23-03-2015
|
data/DEV.md
ADDED
data/Gemfile
CHANGED
@@ -3,28 +3,3 @@ source 'https://rubygems.org'
|
|
3
3
|
|
4
4
|
# Specify your gem's dependencies in message_bus.gemspec
|
5
5
|
gemspec
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'minitest'
|
9
|
-
gem 'minitest-hooks'
|
10
|
-
gem 'minitest-global_expectations'
|
11
|
-
gem 'rake'
|
12
|
-
gem 'http_parser.rb'
|
13
|
-
gem 'thin'
|
14
|
-
gem 'rack-test', require: 'rack/test'
|
15
|
-
gem 'jasmine'
|
16
|
-
gem 'puma'
|
17
|
-
end
|
18
|
-
|
19
|
-
group :test, :development do
|
20
|
-
gem 'byebug'
|
21
|
-
end
|
22
|
-
|
23
|
-
group :development do
|
24
|
-
gem 'yard'
|
25
|
-
gem 'rubocop-discourse', require: false
|
26
|
-
gem 'rubocop-rspec', require: false
|
27
|
-
end
|
28
|
-
|
29
|
-
gem 'rack'
|
30
|
-
gem 'concurrent-ruby' # for distributed-cache
|
data/LICENSE
CHANGED
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -10,15 +10,9 @@ 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
|
-
MessageBus only support officially supported versions of Ruby; as of [
|
15
|
+
MessageBus only support officially supported versions of Ruby; as of [2021-03-31](https://www.ruby-lang.org/en/downloads/branches/) this means we only support Ruby version 2.6 and up.
|
22
16
|
|
23
17
|
## Can you handle concurrent requests?
|
24
18
|
|
@@ -74,19 +68,19 @@ id = MessageBus.last_id("/channel")
|
|
74
68
|
MessageBus.backlog "/channel", id
|
75
69
|
```
|
76
70
|
|
77
|
-
###
|
71
|
+
### Targeted messages
|
78
72
|
|
79
|
-
Messages can be
|
73
|
+
Messages can be targeted to particular clients by supplying the `client_ids` option when publishing a message.
|
80
74
|
|
81
75
|
```ruby
|
82
76
|
MessageBus.publish "/channel", "hello", client_ids: ["XXX", "YYY"] # (using MessageBus.clientId)
|
83
77
|
```
|
84
78
|
|
85
|
-
By configuring the `user_id_lookup` and `group_ids_lookup` options with a Proc or Lambda which will be called with a [Rack specification environment](https://github.com/rack/rack/blob/master/SPEC.rdoc#the-environment-), messages can be
|
79
|
+
By configuring the `user_id_lookup` and `group_ids_lookup` options with a Proc or Lambda which will be called with a [Rack specification environment](https://github.com/rack/rack/blob/master/SPEC.rdoc#the-environment-), messages can be targeted to particular clients users or groups by supplying either the `user_ids` or `group_ids` options when publishing a message.
|
86
80
|
|
87
81
|
```ruby
|
88
82
|
MessageBus.configure(user_id_lookup: proc do |env|
|
89
|
-
# this lookup occurs on JS-client
|
83
|
+
# this lookup occurs on JS-client polling, so that server can retrieve backlog
|
90
84
|
# for the client considering/matching/filtering user_ids set on published messages
|
91
85
|
# if user_id is not set on publish time, any user_id returned here will receive the message
|
92
86
|
# return the user id here
|
@@ -104,7 +98,7 @@ end)
|
|
104
98
|
MessageBus.publish "/channel", "hello", group_ids: [1, 2, 3]
|
105
99
|
|
106
100
|
# example of MessageBus to set user_ids from an initializer in Rails and Devise:
|
107
|
-
# config/
|
101
|
+
# config/initializers/message_bus.rb
|
108
102
|
MessageBus.user_id_lookup do |env|
|
109
103
|
req = Rack::Request.new(env)
|
110
104
|
|
@@ -115,13 +109,13 @@ MessageBus.user_id_lookup do |env|
|
|
115
109
|
end
|
116
110
|
```
|
117
111
|
|
118
|
-
If both `user_ids` and `group_ids` options are supplied when publishing a message, the message will be
|
112
|
+
If both `user_ids` and `group_ids` options are supplied when publishing a message, the message will be targeted at clients with lookup return values that matches on either the `user_ids` **or** the `group_ids` options.
|
119
113
|
|
120
114
|
```ruby
|
121
115
|
MessageBus.publish "/channel", "hello", user_ids: [1, 2, 3], group_ids: [1, 2, 3]
|
122
116
|
```
|
123
117
|
|
124
|
-
If the `client_ids` option is supplied with either the `user_ids` or `group_ids` options when
|
118
|
+
If the `client_ids` option is supplied with either the `user_ids` or `group_ids` options when publishing a message, the `client_ids` option will be applied unconditionally and messages will be filtered further using `user_id` or `group_id` clauses.
|
125
119
|
|
126
120
|
```ruby
|
127
121
|
MessageBus.publish "/channel", "hello", client_ids: ["XXX", "YYY"], user_ids: [1, 2, 3], group_ids: [1, 2, 3]
|
@@ -251,7 +245,7 @@ end)
|
|
251
245
|
MessageBus.publish "/channel", "some message"
|
252
246
|
|
253
247
|
# you can also choose to pass the `:site_id`.
|
254
|
-
# This takes
|
248
|
+
# This takes precedence over whatever `site_id_lookup`
|
255
249
|
# returns
|
256
250
|
MessageBus.publish "/channel", "some message", site_id: "site-id"
|
257
251
|
|
@@ -441,6 +435,31 @@ MessageBus.configure(backend: :memory)
|
|
441
435
|
|
442
436
|
The `:clear_every` option supported by the PostgreSQL backend is also supported by the in-memory backend.
|
443
437
|
|
438
|
+
|
439
|
+
### Transport codecs
|
440
|
+
|
441
|
+
By default MessageBus serializes messages to the backend using JSON. Under most situation this performs extremely well.
|
442
|
+
|
443
|
+
In some exceptional cases you may consider a different transport codec. To configure a custom codec use:
|
444
|
+
|
445
|
+
```ruby
|
446
|
+
MessageBus.configure(transport_codec: codec)
|
447
|
+
```
|
448
|
+
|
449
|
+
A codec class must implement MessageBus::Codec::Base. Specifically an `encode` and `decode` method.
|
450
|
+
|
451
|
+
See the `bench` directory for examples where the default JSON codec can perform poorly. A specific examples may be
|
452
|
+
attempting to distribute a message to a restricted list of thousands of users. In cases like this you may consider
|
453
|
+
using a packed string encoder.
|
454
|
+
|
455
|
+
Keep in mind, much of MessageBus internals and supporting tools expect data to be converted to JSON and back, if you use a naive (and fast) `Marshal` based codec you may need to limit the features you use. Specifically the Postgresql backend expects the codec never to return a string with `\u0000`, additionally some classes like DistributedCache expect keys to be converted to Strings.
|
456
|
+
|
457
|
+
Another example may be very large and complicated messages where Oj in compatibility mode outperforms JSON. To opt for the Oj codec use:
|
458
|
+
|
459
|
+
```
|
460
|
+
MessageBus.configure(transport_codec: MessageBus::Codec::Oj.new)
|
461
|
+
```
|
462
|
+
|
444
463
|
### Forking/threading app servers
|
445
464
|
|
446
465
|
If you're using a forking or threading app server and you're not getting immediate delivery of published messages, you might need to configure your web server to re-connect to the message_bus backend
|
data/Rakefile
CHANGED
@@ -4,12 +4,8 @@ require 'rake/testtask'
|
|
4
4
|
require 'bundler'
|
5
5
|
require 'bundler/gem_tasks'
|
6
6
|
require 'bundler/setup'
|
7
|
-
require 'jasmine'
|
8
|
-
|
9
|
-
ENV['JASMINE_CONFIG_PATH'] ||= File.join(Dir.pwd, 'spec', 'assets', 'support', 'jasmine.yml')
|
10
|
-
load 'jasmine/tasks/jasmine.rake'
|
11
|
-
|
12
7
|
require 'rubocop/rake_task'
|
8
|
+
|
13
9
|
RuboCop::RakeTask.new
|
14
10
|
|
15
11
|
require 'yard'
|
@@ -35,7 +31,14 @@ module Bundler
|
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
|
-
|
34
|
+
namespace :jasmine do
|
35
|
+
desc "Run Jasmine tests in headless mode"
|
36
|
+
task 'ci' do
|
37
|
+
if !system("npx jasmine-browser-runner runSpecs")
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
43
|
backends = Dir["lib/message_bus/backends/*.rb"].map { |file| file.match(%r{backends/(?<backend>.*).rb})[:backend] } - ["base"]
|
41
44
|
|
@@ -57,6 +60,8 @@ namespace :spec do
|
|
57
60
|
|
58
61
|
desc "Run integration tests"
|
59
62
|
task :integration do
|
63
|
+
require "socket"
|
64
|
+
|
60
65
|
def port_available?(port)
|
61
66
|
server = TCPServer.open("0.0.0.0", port)
|
62
67
|
server.close
|
@@ -78,7 +83,7 @@ namespace :spec do
|
|
78
83
|
end
|
79
84
|
|
80
85
|
desc "Run tests on all backends, plus client JS tests"
|
81
|
-
task spec: backends.map { |backend| "spec:#{backend}" } + [:
|
86
|
+
task spec: backends.map { |backend| "spec:#{backend}" } + ["jasmine:ci", "spec:integration"]
|
82
87
|
|
83
88
|
desc "Run performance benchmarks on all backends"
|
84
89
|
task :performance do
|
@@ -94,5 +99,5 @@ desc "Run all tests, link checks and confirms documentation compiles without err
|
|
94
99
|
task default: [:spec, :rubocop, :test_doc]
|
95
100
|
|
96
101
|
Rake::Task['release'].enhance do
|
97
|
-
sh "
|
102
|
+
sh "yarn publish"
|
98
103
|
end
|
data/assets/message-bus-ajax.js
CHANGED
@@ -2,27 +2,21 @@
|
|
2
2
|
// as a fallback if jQuery is not present
|
3
3
|
//
|
4
4
|
// Only implements methods & options used by MessageBus
|
5
|
-
(function(global
|
5
|
+
(function(global) {
|
6
6
|
'use strict';
|
7
7
|
if (!global.MessageBus){
|
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
|
}
|
25
|
-
xhr.setRequestHeader('Content-Type', 'application/
|
19
|
+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
26
20
|
if (options.messageBus.chunked){
|
27
21
|
options.messageBus.onProgressListener(xhr);
|
28
22
|
}
|
@@ -37,7 +31,7 @@
|
|
37
31
|
options.complete();
|
38
32
|
}
|
39
33
|
}
|
40
|
-
xhr.send(
|
34
|
+
xhr.send(new URLSearchParams(options.data).toString());
|
41
35
|
return xhr;
|
42
36
|
};
|
43
37
|
|