message_bus 3.3.6 → 3.3.7
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 +10 -2
- data/.github/workflows/ci.yml +36 -19
- data/CHANGELOG +15 -8
- data/DEV.md +0 -2
- data/Gemfile +0 -27
- data/LICENSE +1 -1
- data/README.md +10 -10
- data/Rakefile +12 -7
- data/assets/message-bus-ajax.js +3 -3
- data/bench/codecs/marshal.rb +1 -1
- data/bench/codecs/packed_string.rb +1 -1
- data/examples/bench/bench.lua +2 -2
- data/lib/message_bus/backends/base.rb +3 -3
- data/lib/message_bus/backends/postgres.rb +7 -3
- data/lib/message_bus/backends/redis.rb +1 -1
- data/lib/message_bus/client.rb +3 -7
- data/lib/message_bus/connection_manager.rb +1 -1
- data/lib/message_bus/distributed_cache.rb +2 -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 +6 -0
- data/lib/message_bus/rack/thin_ext.rb +1 -1
- data/lib/message_bus/version.rb +1 -1
- data/lib/message_bus.rb +6 -6
- data/message_bus.gemspec +20 -5
- data/package-lock.json +1575 -23
- data/package.json +7 -2
- data/spec/assets/SpecHelper.js +6 -5
- data/spec/assets/message-bus.spec.js +9 -6
- data/spec/helpers.rb +17 -6
- data/spec/integration/http_client_spec.rb +1 -1
- data/spec/lib/message_bus/backend_spec.rb +12 -44
- data/spec/lib/message_bus/client_spec.rb +6 -6
- data/spec/lib/message_bus/distributed_cache_spec.rb +5 -7
- data/spec/lib/message_bus/multi_process_spec.rb +1 -1
- data/spec/lib/message_bus/rack/middleware_spec.rb +16 -5
- data/spec/lib/message_bus_spec.rb +10 -6
- data/spec/spec_helper.rb +8 -9
- data/spec/support/jasmine-browser.json +16 -0
- metadata +220 -14
- data/spec/assets/support/jasmine.yml +0 -126
- data/spec/assets/support/jasmine_helper.rb +0 -11
- data/vendor/assets/javascripts/message-bus-ajax.js +0 -38
- data/vendor/assets/javascripts/message-bus.js +0 -549
data/package.json
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
"version": "3.3.5",
|
4
4
|
"description": "A message bus client in Javascript",
|
5
5
|
"main": "assets/message-bus.js",
|
6
|
-
"keywords":
|
6
|
+
"keywords": [
|
7
|
+
"es6",
|
8
|
+
"modules"
|
9
|
+
],
|
7
10
|
"files": [
|
8
11
|
"assets/message-bus.js"
|
9
12
|
],
|
@@ -20,6 +23,8 @@
|
|
20
23
|
},
|
21
24
|
"homepage": "https://github.com/discourse/message_bus#readme",
|
22
25
|
"devDependencies": {
|
23
|
-
"eslint": "^7.27.0"
|
26
|
+
"eslint": "^7.27.0",
|
27
|
+
"jasmine-browser-runner": "^0.10.0",
|
28
|
+
"jasmine-core": "^3.10.1"
|
24
29
|
}
|
25
30
|
}
|
data/spec/assets/SpecHelper.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/* global beforeEach, afterEach, it, spyOn, MessageBus */
|
2
|
+
|
1
3
|
var message_id = 1;
|
2
4
|
var SEPARATOR = "\r\n|\r\n";
|
3
5
|
|
@@ -12,7 +14,7 @@ var encodeChunks = function(xhr, chunks) {
|
|
12
14
|
}
|
13
15
|
if (xhr.onprogress){ // using longPoll if onprogress is set
|
14
16
|
var responses = []
|
15
|
-
for (var
|
17
|
+
for (var j=0;j<chunks.length;j++) {
|
16
18
|
responses.push( JSON.stringify([chunk]) );
|
17
19
|
}
|
18
20
|
return responses.join(SEPARATOR) + SEPARATOR;
|
@@ -26,7 +28,7 @@ beforeEach(function () {
|
|
26
28
|
|
27
29
|
function MockedXMLHttpRequest(){
|
28
30
|
this.headers = {};
|
29
|
-
}
|
31
|
+
}
|
30
32
|
|
31
33
|
MockedXMLHttpRequest.prototype.send = function(){
|
32
34
|
this.readyState = 4
|
@@ -75,8 +77,8 @@ window.testMB = function(description, testFn, path, data){
|
|
75
77
|
{channel: path || '/test', data: data || {password: 'MessageBusRocks!'}}
|
76
78
|
];
|
77
79
|
it(description, function(done){
|
78
|
-
spec = this;
|
79
|
-
promisy = {
|
80
|
+
var spec = this;
|
81
|
+
var promisy = {
|
80
82
|
finally: function(fn){
|
81
83
|
this.resolve = fn;
|
82
84
|
}
|
@@ -105,4 +107,3 @@ window.testMB = function(description, testFn, path, data){
|
|
105
107
|
});
|
106
108
|
|
107
109
|
}
|
108
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/* global describe, it, spyOn, MessageBus, expect, jasmine, testMB */
|
2
|
+
|
1
3
|
describe("Messagebus", function() {
|
2
4
|
|
3
5
|
it("submits change requests", function(done){
|
@@ -6,10 +8,11 @@ describe("Messagebus", function() {
|
|
6
8
|
MessageBus.subscribe('/test', function(){
|
7
9
|
expect(spec.MockedXMLHttpRequest.prototype.send)
|
8
10
|
.toHaveBeenCalled()
|
9
|
-
var
|
10
|
-
|
11
|
-
expect(
|
12
|
-
|
11
|
+
var data = spec.MockedXMLHttpRequest.prototype.send.calls.argsFor(0)[0];
|
12
|
+
var params = new URLSearchParams(data);
|
13
|
+
expect(params.get("/test")).toEqual("-1");
|
14
|
+
expect(params.get("__seq")).toMatch(/\d+/);
|
15
|
+
done();
|
13
16
|
});
|
14
17
|
});
|
15
18
|
|
@@ -57,7 +60,7 @@ describe("Messagebus", function() {
|
|
57
60
|
});
|
58
61
|
});
|
59
62
|
|
60
|
-
testMB('sets dlp
|
63
|
+
testMB('sets dlp parameter when longPolling is disabled', function(){
|
61
64
|
MessageBus.enableLongPolling = false
|
62
65
|
this.perform(function(message, xhr){
|
63
66
|
expect(xhr.url).toMatch("dlp=t");
|
@@ -87,7 +90,7 @@ describe("Messagebus", function() {
|
|
87
90
|
expect(xhr.headers).toEqual({
|
88
91
|
'X-SILENCE-LOGGER': 'true',
|
89
92
|
'X-MB-TEST-VALUE': '42',
|
90
|
-
'Content-Type': 'application/
|
93
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
91
94
|
});
|
92
95
|
}).finally(function(){
|
93
96
|
MessageBus.headers = {};
|
data/spec/helpers.rb
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require 'method_source'
|
5
|
+
|
6
|
+
def wait_for(timeout_milliseconds = 2000, &blk)
|
7
|
+
timeout = timeout_milliseconds / 1000.0
|
4
8
|
finish = Time.now + timeout
|
9
|
+
result = nil
|
5
10
|
|
6
|
-
|
7
|
-
sleep(0.001)
|
8
|
-
end
|
11
|
+
while Time.now < finish && !(result = blk.call)
|
12
|
+
sleep(0.001)
|
13
|
+
end
|
14
|
+
|
15
|
+
flunk("wait_for timed out:\n#{blk.source}") if !result
|
9
16
|
end
|
10
17
|
|
11
18
|
def test_config_for_backend(backend)
|
12
|
-
config = {
|
19
|
+
config = {
|
20
|
+
backend: backend,
|
21
|
+
logger: Logger.new(IO::NULL),
|
22
|
+
}
|
23
|
+
|
13
24
|
case backend
|
14
25
|
when :redis
|
15
26
|
config[:url] = ENV['REDISURL']
|
@@ -71,7 +71,7 @@ describe MessageBus::HTTPClient do
|
|
71
71
|
# that we sleep for the right interval after failure
|
72
72
|
sleep 0.5
|
73
73
|
|
74
|
-
|
74
|
+
assert_match(/Errno::ECONNREFUSED|SocketError/, fake.string)
|
75
75
|
ensure
|
76
76
|
$stderr = original_stderr
|
77
77
|
end
|
@@ -4,18 +4,17 @@ require_relative '../../spec_helper'
|
|
4
4
|
require 'message_bus'
|
5
5
|
|
6
6
|
describe PUB_SUB_CLASS do
|
7
|
-
|
8
|
-
PUB_SUB_CLASS.new(
|
7
|
+
before do
|
8
|
+
@bus = PUB_SUB_CLASS.new(test_config_for_backend(CURRENT_BACKEND))
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
@bus = new_test_bus
|
11
|
+
after do
|
13
12
|
@bus.reset!
|
14
13
|
end
|
15
14
|
|
16
15
|
describe "API parity" do
|
17
16
|
it "has the same public methods as the base class" do
|
18
|
-
@bus.public_methods.sort.must_equal MessageBus::Backends::Base.new(
|
17
|
+
@bus.public_methods.sort.must_equal MessageBus::Backends::Base.new(test_config_for_backend(CURRENT_BACKEND)).public_methods.sort
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -77,7 +76,7 @@ describe PUB_SUB_CLASS do
|
|
77
76
|
end
|
78
77
|
|
79
78
|
threads.each(&:join)
|
80
|
-
@bus.backlog("/foo").length
|
79
|
+
@bus.backlog("/foo").length.must_equal 100
|
81
80
|
end
|
82
81
|
|
83
82
|
it "should be able to encode and decode messages properly" do
|
@@ -91,37 +90,6 @@ describe PUB_SUB_CLASS do
|
|
91
90
|
@bus.last_id("/foo").must_equal 1
|
92
91
|
end
|
93
92
|
|
94
|
-
describe "readonly" do
|
95
|
-
after do
|
96
|
-
@bus.pub_redis.slaveof "no", "one"
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should be able to store messages in memory for a period while in read only" do
|
100
|
-
test_only :redis
|
101
|
-
skip "This spec changes redis behavior that in turn means other specs run slow"
|
102
|
-
|
103
|
-
@bus.pub_redis.slaveof "127.0.0.80", "666"
|
104
|
-
@bus.max_in_memory_publish_backlog = 2
|
105
|
-
|
106
|
-
current_threads = Thread.list
|
107
|
-
current_threads_length = current_threads.count
|
108
|
-
|
109
|
-
3.times do
|
110
|
-
result = @bus.publish "/foo", "bar"
|
111
|
-
assert_nil result
|
112
|
-
Thread.list.length.must_equal(current_threads_length + 1)
|
113
|
-
end
|
114
|
-
|
115
|
-
@bus.pub_redis.slaveof "no", "one"
|
116
|
-
sleep 0.01
|
117
|
-
|
118
|
-
(Thread.list - current_threads).each(&:join)
|
119
|
-
Thread.list.length.must_equal current_threads_length
|
120
|
-
|
121
|
-
@bus.backlog("/foo", 0).map(&:data).must_equal ["bar", "bar"]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
93
|
it "can set backlog age" do
|
126
94
|
@bus.max_backlog_age = 1
|
127
95
|
|
@@ -137,7 +105,7 @@ describe PUB_SUB_CLASS do
|
|
137
105
|
sleep 1.25 # Should now be at time =~ 1.25s. Our backlog should have expired by now.
|
138
106
|
expected_backlog_size = 0
|
139
107
|
|
140
|
-
case
|
108
|
+
case CURRENT_BACKEND
|
141
109
|
when :postgres
|
142
110
|
# Force triggering backlog expiry: postgres backend doesn't expire backlogs on a timer, but at publication time.
|
143
111
|
@bus.global_backlog.length.wont_equal expected_backlog_size
|
@@ -161,7 +129,7 @@ describe PUB_SUB_CLASS do
|
|
161
129
|
@bus.publish "/foo", "baz" # Publish something else to ward off another expiry
|
162
130
|
expected_backlog_size += 1
|
163
131
|
|
164
|
-
case
|
132
|
+
case CURRENT_BACKEND
|
165
133
|
when :postgres
|
166
134
|
# Postgres expires individual messages that have lived longer than the TTL, not whole backlogs
|
167
135
|
expected_backlog_size -= 1
|
@@ -189,7 +157,7 @@ describe PUB_SUB_CLASS do
|
|
189
157
|
sleep 1.25 # Should now be at time =~ 1.25s. Our backlog should have expired by now.
|
190
158
|
expected_backlog_size = 0
|
191
159
|
|
192
|
-
case
|
160
|
+
case CURRENT_BACKEND
|
193
161
|
when :postgres
|
194
162
|
# Force triggering backlog expiry: postgres backend doesn't expire backlogs on a timer, but at publication time.
|
195
163
|
@bus.global_backlog.length.wont_equal expected_backlog_size
|
@@ -204,7 +172,7 @@ describe PUB_SUB_CLASS do
|
|
204
172
|
|
205
173
|
# for the time being we can give pg a pass here
|
206
174
|
# TODO: make the implementation here consistent
|
207
|
-
if
|
175
|
+
if CURRENT_BACKEND != :postgres
|
208
176
|
# ids are not opaque we expect them to be reset on our channel if it
|
209
177
|
# got cleared due to an expire, the reason for this is cause we will leak entries due to tracking
|
210
178
|
# this in turn can bloat storage for the backend
|
@@ -222,7 +190,7 @@ describe PUB_SUB_CLASS do
|
|
222
190
|
@bus.publish "/foo", "baz", max_backlog_age: 1 # Publish something else to ward off another expiry
|
223
191
|
expected_backlog_size += 1
|
224
192
|
|
225
|
-
case
|
193
|
+
case CURRENT_BACKEND
|
226
194
|
when :postgres
|
227
195
|
# Postgres expires individual messages that have lived longer than the TTL, not whole backlogs
|
228
196
|
expected_backlog_size -= 1
|
@@ -249,7 +217,7 @@ describe PUB_SUB_CLASS do
|
|
249
217
|
@bus.publish "/foo", "baz"
|
250
218
|
@bus.publish "/hello", "planet"
|
251
219
|
|
252
|
-
expected_messages = case
|
220
|
+
expected_messages = case CURRENT_BACKEND
|
253
221
|
when :redis
|
254
222
|
# Redis has channel-specific message IDs
|
255
223
|
[
|
@@ -277,7 +245,7 @@ describe PUB_SUB_CLASS do
|
|
277
245
|
@bus.publish "/bar", "a1"
|
278
246
|
@bus.publish "/bar", "b1"
|
279
247
|
|
280
|
-
expected_messages = case
|
248
|
+
expected_messages = case CURRENT_BACKEND
|
281
249
|
when :redis
|
282
250
|
# Redis has channel-specific message IDs
|
283
251
|
[
|
@@ -11,7 +11,7 @@ describe MessageBus::Client do
|
|
11
11
|
|
12
12
|
before do
|
13
13
|
@bus = MessageBus::Instance.new
|
14
|
-
@bus.configure(
|
14
|
+
@bus.configure(test_config_for_backend(CURRENT_BACKEND))
|
15
15
|
@client = setup_client('abc')
|
16
16
|
end
|
17
17
|
|
@@ -98,7 +98,7 @@ describe MessageBus::Client do
|
|
98
98
|
chunk2.length.must_equal 0
|
99
99
|
end
|
100
100
|
|
101
|
-
it "does not bleed data
|
101
|
+
it "does not bleed data across sites" do
|
102
102
|
@client.site_id = "test"
|
103
103
|
|
104
104
|
@client.subscribe('/hello', nil)
|
@@ -107,7 +107,7 @@ describe MessageBus::Client do
|
|
107
107
|
log.length.must_equal 0
|
108
108
|
end
|
109
109
|
|
110
|
-
it "does not bleed status
|
110
|
+
it "does not bleed status across sites" do
|
111
111
|
@client.site_id = "test"
|
112
112
|
|
113
113
|
@client.subscribe('/hello', -1)
|
@@ -190,7 +190,7 @@ describe MessageBus::Client do
|
|
190
190
|
@client.allowed?(@message).must_equal true
|
191
191
|
end
|
192
192
|
|
193
|
-
describe '
|
193
|
+
describe 'targeted at user' do
|
194
194
|
before do
|
195
195
|
@message = MessageBus::Message.new(1, 2, '/test', 'hello')
|
196
196
|
@message.user_ids = [1, 2, 3]
|
@@ -241,7 +241,7 @@ describe MessageBus::Client do
|
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
-
describe "
|
244
|
+
describe "targeted at group" do
|
245
245
|
before do
|
246
246
|
@message = MessageBus::Message.new(1, 2, '/test', 'hello')
|
247
247
|
@message.group_ids = [1, 2, 3]
|
@@ -291,7 +291,7 @@ describe MessageBus::Client do
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
describe '
|
294
|
+
describe 'targeted at group and user' do
|
295
295
|
before do
|
296
296
|
@message = MessageBus::Message.new(1, 2, '/test', 'hello')
|
297
297
|
@message.group_ids = [1, 2, 3]
|
@@ -6,13 +6,16 @@ require 'message_bus'
|
|
6
6
|
require 'message_bus/distributed_cache'
|
7
7
|
|
8
8
|
describe MessageBus::DistributedCache do
|
9
|
-
before
|
9
|
+
before do
|
10
10
|
@bus = MessageBus::Instance.new
|
11
11
|
@bus.configure(backend: :memory)
|
12
12
|
@manager = MessageBus::DistributedCache::Manager.new(@bus)
|
13
|
+
@cache1 = cache(cache_name)
|
14
|
+
@cache2 = cache(cache_name)
|
13
15
|
end
|
14
16
|
|
15
|
-
after
|
17
|
+
after do
|
18
|
+
@bus.reset!
|
16
19
|
@bus.destroy
|
17
20
|
end
|
18
21
|
|
@@ -24,11 +27,6 @@ describe MessageBus::DistributedCache do
|
|
24
27
|
SecureRandom.hex
|
25
28
|
end
|
26
29
|
|
27
|
-
before do
|
28
|
-
@cache1 = cache(cache_name)
|
29
|
-
@cache2 = cache(cache_name)
|
30
|
-
end
|
31
|
-
|
32
30
|
it 'supports arrays with hashes' do
|
33
31
|
c1 = cache("test1")
|
34
32
|
c2 = cache("test1")
|
@@ -12,7 +12,7 @@ describe MessageBus::Rack::Middleware do
|
|
12
12
|
|
13
13
|
before do
|
14
14
|
bus = @bus = MessageBus::Instance.new
|
15
|
-
@bus.configure(
|
15
|
+
@bus.configure(test_config_for_backend(CURRENT_BACKEND))
|
16
16
|
@bus.long_polling_enabled = false
|
17
17
|
@bus.base_route = base_route if base_route
|
18
18
|
|
@@ -26,7 +26,6 @@ describe MessageBus::Rack::Middleware do
|
|
26
26
|
|
27
27
|
@async_middleware = builder.to_app
|
28
28
|
@message_bus_middleware = @async_middleware.app
|
29
|
-
@bus.reset!
|
30
29
|
end
|
31
30
|
|
32
31
|
after do
|
@@ -143,13 +142,12 @@ describe MessageBus::Rack::Middleware do
|
|
143
142
|
end
|
144
143
|
|
145
144
|
describe "diagnostics" do
|
146
|
-
it "should return a 403 if
|
145
|
+
it "should return a 403 if an unauthorized user attempts to get at the _diagnostics path" do
|
147
146
|
get "/message-bus/_diagnostics"
|
148
147
|
last_response.status.must_equal 403
|
149
148
|
end
|
150
149
|
|
151
150
|
it "should get a 200 with html for an authorized user" do
|
152
|
-
|
153
151
|
def @bus.is_admin_lookup
|
154
152
|
proc { |_| true }
|
155
153
|
end
|
@@ -172,7 +170,6 @@ describe MessageBus::Rack::Middleware do
|
|
172
170
|
end
|
173
171
|
|
174
172
|
it "should get the script it asks for" do
|
175
|
-
|
176
173
|
def @bus.is_admin_lookup
|
177
174
|
proc { |_| true }
|
178
175
|
end
|
@@ -181,6 +178,15 @@ describe MessageBus::Rack::Middleware do
|
|
181
178
|
last_response.status.must_equal 200
|
182
179
|
last_response.content_type.must_equal "application/javascript;charset=UTF-8"
|
183
180
|
end
|
181
|
+
|
182
|
+
it "should return 404 for invalid assets path" do
|
183
|
+
def @bus.is_admin_lookup
|
184
|
+
proc { |_| true }
|
185
|
+
end
|
186
|
+
|
187
|
+
get "/message-bus/_diagnostics/assets/../Gemfile"
|
188
|
+
last_response.status.must_equal 404
|
189
|
+
end
|
184
190
|
end
|
185
191
|
|
186
192
|
describe "polling" do
|
@@ -414,6 +420,11 @@ describe MessageBus::Rack::Middleware do
|
|
414
420
|
JSON.parse(last_response.body).first["data"].must_equal('json' => true)
|
415
421
|
end
|
416
422
|
|
423
|
+
it "should tell Rack to skip committing the session" do
|
424
|
+
post "/message-bus/1234", {}, { "rack.session.options" => {} }
|
425
|
+
last_request.env["rack.session.options"][:skip].must_equal true
|
426
|
+
end
|
427
|
+
|
417
428
|
describe "on_middleware_error handling" do
|
418
429
|
it "allows error handling of middleware failures" do
|
419
430
|
@bus.on_middleware_error do |_env, err|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
require 'message_bus'
|
5
|
-
require 'redis'
|
6
5
|
|
7
6
|
describe MessageBus do
|
8
7
|
before do
|
@@ -10,7 +9,7 @@ describe MessageBus do
|
|
10
9
|
@bus.site_id_lookup do
|
11
10
|
"magic"
|
12
11
|
end
|
13
|
-
@bus.configure(
|
12
|
+
@bus.configure(test_config_for_backend(CURRENT_BACKEND))
|
14
13
|
end
|
15
14
|
|
16
15
|
after do
|
@@ -98,7 +97,7 @@ describe MessageBus do
|
|
98
97
|
client_ids.must_equal ['a', 'b']
|
99
98
|
end
|
100
99
|
|
101
|
-
it "should recover from a
|
100
|
+
it "should recover from a reset" do
|
102
101
|
data = nil
|
103
102
|
@bus.subscribe("/chuck") do |msg|
|
104
103
|
data = msg.data
|
@@ -307,7 +306,7 @@ describe MessageBus do
|
|
307
306
|
end
|
308
307
|
end
|
309
308
|
|
310
|
-
it "should support forking properly
|
309
|
+
it "should support forking properly" do
|
311
310
|
test_never :memory
|
312
311
|
|
313
312
|
data = []
|
@@ -316,7 +315,7 @@ describe MessageBus do
|
|
316
315
|
end
|
317
316
|
|
318
317
|
@bus.publish("/hello", "pre-fork")
|
319
|
-
wait_for(2000) { data.length
|
318
|
+
wait_for(2000) { data.length == 1 }
|
320
319
|
|
321
320
|
if child = Process.fork
|
322
321
|
# The child was forked and we received its PID
|
@@ -328,6 +327,7 @@ describe MessageBus do
|
|
328
327
|
else
|
329
328
|
begin
|
330
329
|
@bus.after_fork
|
330
|
+
GC.start
|
331
331
|
@bus.publish("/hello", "from-fork")
|
332
332
|
ensure
|
333
333
|
exit!(0)
|
@@ -336,7 +336,11 @@ describe MessageBus do
|
|
336
336
|
|
337
337
|
wait_for(2000) { data.length == 3 }
|
338
338
|
|
339
|
-
|
339
|
+
@bus.publish("/hello", "after-fork")
|
340
|
+
|
341
|
+
wait_for(2000) { data.length == 4 }
|
342
|
+
|
343
|
+
data.must_equal(["pre-fork", "from-fork", "continuation", "after-fork"])
|
340
344
|
end
|
341
345
|
|
342
346
|
describe '#register_client_message_filter' do
|
data/spec/spec_helper.rb
CHANGED
@@ -11,18 +11,17 @@ require 'minitest/global_expectations'
|
|
11
11
|
|
12
12
|
require_relative "helpers"
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
require "message_bus/backends/#{
|
17
|
-
PUB_SUB_CLASS = MessageBus::BACKENDS.fetch(
|
18
|
-
|
14
|
+
CURRENT_BACKEND = (ENV['MESSAGE_BUS_BACKEND'] || :redis).to_sym
|
15
|
+
|
16
|
+
require "message_bus/backends/#{CURRENT_BACKEND}"
|
17
|
+
PUB_SUB_CLASS = MessageBus::BACKENDS.fetch(CURRENT_BACKEND)
|
18
|
+
|
19
|
+
puts "Running with backend: #{CURRENT_BACKEND}"
|
19
20
|
|
20
21
|
def test_only(*backends)
|
21
|
-
|
22
|
-
skip "Test doesn't apply to #{backend}" unless backends.include?(backend)
|
22
|
+
skip "Test doesn't apply to #{CURRENT_BACKEND}" unless backends.include?(CURRENT_BACKEND)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_never(*backends)
|
26
|
-
|
27
|
-
skip "Test doesn't apply to #{backend}" if backends.include?(backend)
|
26
|
+
skip "Test doesn't apply to #{CURRENT_BACKEND}" if backends.include?(CURRENT_BACKEND)
|
28
27
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"srcDir": "assets",
|
3
|
+
"srcFiles": [
|
4
|
+
"message-bus.js",
|
5
|
+
"message-bus-ajax.js"
|
6
|
+
],
|
7
|
+
"specDir": "spec/assets",
|
8
|
+
"specFiles": [
|
9
|
+
"message-bus.spec.js"
|
10
|
+
],
|
11
|
+
"helpers": [
|
12
|
+
"SpecHelper.js"
|
13
|
+
],
|
14
|
+
"random": true,
|
15
|
+
"browser": "headlessChrome"
|
16
|
+
}
|