message_bus 3.3.8 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -0
- data/CHANGELOG +82 -46
- data/README.md +27 -19
- data/Rakefile +22 -22
- data/lib/message_bus/backends/postgres.rb +1 -0
- data/lib/message_bus/backends/redis.rb +1 -0
- data/lib/message_bus/version.rb +1 -1
- data/lib/message_bus.rb +3 -26
- data/spec/lib/message_bus/multi_process_spec.rb +1 -0
- data/spec/lib/message_bus/timer_thread_spec.rb +1 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9967cb1c20e9a7c2f02ea36bfd54a3a13dac00ef44dcd0f27f7f878504ee2c
|
4
|
+
data.tar.gz: 6ad58769e032468f20411b507aab0c7eaf72e09ab904641f1f635a5061c42c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f3ab3af97533e26cf7fc91eb529dd5bd90f7e3b7a818b6c86636bbd4cbfb5b8f38479ee81ca1230da1ec5d6101d59a56273186f46c8d3b52807a467c40abdb
|
7
|
+
data.tar.gz: ab4a57f673a4cb99c1a00225a041dfe69dfbc6f9c7213774a6e4f64e6250241d3c69148fc14cf900409e15f1574d0a6b41be43b9b3c5819f2313d25ab0713418
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
31-12-2021
|
2
|
+
|
3
|
+
- Version 3.4.0
|
4
|
+
|
5
|
+
- FEATURE: remove "suicide" feature from message_bus - (message_bus used to terminate process when keepalive exceeded)
|
6
|
+
|
7
|
+
20-12-2021
|
8
|
+
|
9
|
+
- Version 3.3.8
|
10
|
+
|
11
|
+
- FIX: Restore dist js files to fix a regression in 3.3.7
|
12
|
+
- FIX: Stop various thread/pg connection leaks
|
13
|
+
- DEV: Fix ruby warnings
|
14
|
+
|
1
15
|
15-12-2021
|
2
16
|
|
3
17
|
- Version 3.3.7
|
@@ -63,14 +77,14 @@
|
|
63
77
|
|
64
78
|
- Version 3.3.0
|
65
79
|
|
66
|
-
|
80
|
+
- FEATURE: `MessageBus.base_route=` to alter the route that message bus will listen on.
|
67
81
|
|
68
82
|
07-05-2020
|
69
83
|
|
70
84
|
- Version 3.2.0
|
71
85
|
|
72
|
-
|
73
|
-
|
86
|
+
- FIX: compatibility with Rails 6.0.3, note: apps without ActionDispatch::Flash may stop working after this upgrade
|
87
|
+
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)`
|
74
88
|
|
75
89
|
28-04-2020
|
76
90
|
|
@@ -105,7 +119,6 @@
|
|
105
119
|
|
106
120
|
- FIX: In the redis backend make the `is_readonly?` method compatible with the redis gem both pre and post v4.0 when the `client` attribute was removed
|
107
121
|
|
108
|
-
|
109
122
|
30-04-2019
|
110
123
|
|
111
124
|
- Version 2.2.1
|
@@ -136,7 +149,7 @@
|
|
136
149
|
- Version 2.2.0.pre
|
137
150
|
|
138
151
|
- FIX: In redis backend we now expire the key used to track channel id this can cause a redis key leak
|
139
|
-
|
152
|
+
with large amounts of subscriptions that go away
|
140
153
|
- FEATURE: Much extra implementation documentation, and some improvements to usage documentation.
|
141
154
|
- FEATURE: Improvements to development workflow:
|
142
155
|
- Fully docker-based development and testing, with no other dependencies.
|
@@ -153,44 +166,47 @@
|
|
153
166
|
- Supports setting backlog size on publication for memory/postgres
|
154
167
|
- FEATURE: `MessageBus.off` now prevents the server subscription from starting up.
|
155
168
|
- FEATURE: Trims unused parts of the public API:
|
169
|
+
|
156
170
|
- Methods removed:
|
157
|
-
|
158
|
-
|
171
|
+
|
172
|
+
- ConnectionManager#stats (never used and the ConnectionManager is not exposed to application code)
|
173
|
+
- Client#cancel (effectively duplicate of Client#close and the Client is only available via the ConnectionManager, thus not available to application code)
|
159
174
|
|
160
175
|
- Methods made private:
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
|
177
|
+
- MessageBus::Implementation#encode_channel_name
|
178
|
+
- MessageBus::Implementation#decode_channel_name
|
179
|
+
- Client#in_async?
|
180
|
+
- Client#ensure_closed!
|
181
|
+
- ConnectionManager#subscribe_client
|
182
|
+
- Diagnostics.full_process_path
|
183
|
+
- Diagnostics.hostname
|
184
|
+
- MessageBus::Rack::Diagnostics#js_asset
|
185
|
+
- MessageBus::Rack::Diagnostics#generate_script_tag
|
186
|
+
- MessageBus::Rack::Diagnostics#file_hash
|
187
|
+
- MessageBus::Rack::Diagnostics#asset_contents
|
188
|
+
- MessageBus::Rack::Diagnostics#asset_path
|
189
|
+
- MessageBus::Rack::Diagnostics#index
|
190
|
+
- MessageBus::Rack::Diagnostics#translate_handlebars
|
191
|
+
- MessageBus::Rack::Diagnostics#indent
|
192
|
+
- MessageBus::Rack::Middleware#start_listener
|
193
|
+
- MessageBus::Rack::Middleware#close_db_connection!
|
194
|
+
- MessageBus::Rack::Middleware#add_client_with_timeout
|
179
195
|
|
180
196
|
- Methods switched from protected to private:
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
197
|
+
- MessageBus::Implementation#global?
|
198
|
+
- MessageBus::Implementation#decode_message!
|
199
|
+
- MessageBus::Implementation#replay_backlog
|
200
|
+
- MessageBus::Implementation#subscribe_impl
|
201
|
+
- MessageBus::Implementation#unsubscribe_impl
|
202
|
+
- MessageBus::Implementation#ensure_subscriber_thread
|
203
|
+
- MessageBus::Implementation#new_subscriber_thread
|
204
|
+
- MessageBus::Implementation#global_subscribe_thread
|
205
|
+
- MessageBus::Implementation#multi_each
|
206
|
+
- Client#write_headers
|
207
|
+
- Client#write_chunk
|
208
|
+
- Client#write_and_close
|
209
|
+
- Client#messages_to_json
|
194
210
|
|
195
211
|
15-10-2018
|
196
212
|
|
@@ -219,7 +235,7 @@
|
|
219
235
|
- Version 2.1.2
|
220
236
|
|
221
237
|
- FEATURE: minHiddenPollInterval set to 1500ms out of the box, ensures we never do hidden tab
|
222
|
-
|
238
|
+
polls at a high rate if tons of tabs are open
|
223
239
|
- FEATURE: added random 500ms to delayed polls to increase tab entropy
|
224
240
|
|
225
241
|
18-12-2017
|
@@ -233,7 +249,7 @@
|
|
233
249
|
- Version 2.1.0
|
234
250
|
|
235
251
|
- FEATURE: you can now lookup last N messages on channel on subscribe from JavaScript
|
236
|
-
|
252
|
+
Subscribe at position (-1 - numberOfMessages) from the client
|
237
253
|
|
238
254
|
24-11-2017
|
239
255
|
|
@@ -253,8 +269,7 @@
|
|
253
269
|
- Version 2.0.7
|
254
270
|
|
255
271
|
- Fix/Feature: use LUA script for publishing to bus, this eliminates a race condition
|
256
|
-
|
257
|
-
|
272
|
+
and ensures that we are never stuck in a multi transaction by mistake
|
258
273
|
|
259
274
|
29-09-2017
|
260
275
|
|
@@ -282,12 +297,10 @@
|
|
282
297
|
- Version 2.0.2
|
283
298
|
- Feature: Add on_middleware_error callback for remapping middleware errors to HTTP results
|
284
299
|
|
285
|
-
|
286
300
|
25-07-2016
|
287
301
|
|
288
302
|
- Feature: Add JavaScript MessageBus.status() function
|
289
303
|
|
290
|
-
|
291
304
|
21-06-2016
|
292
305
|
|
293
306
|
- Version 2.0.1
|
@@ -368,8 +381,8 @@
|
|
368
381
|
|
369
382
|
- Version 1.1.1
|
370
383
|
- Fix: In multisite config there was no way to specify site for last_id or backlog
|
371
|
-
|
372
|
-
|
384
|
+
to resolve overrides were added to #last_id and #backlog, MessageBus::Client now
|
385
|
+
uses the new overrides
|
373
386
|
|
374
387
|
07-12-2015
|
375
388
|
|
@@ -379,86 +392,105 @@
|
|
379
392
|
- Feature: remove most jQuery dependency from message-bus.js
|
380
393
|
|
381
394
|
09-07-2015
|
395
|
+
|
382
396
|
- Version 1.0.16
|
383
397
|
- Fix: correct edge cases around keepalive checks on bus
|
384
398
|
|
385
399
|
09-07-2015
|
400
|
+
|
386
401
|
- Version 1.0.15
|
387
402
|
- Feature: MessageBus.reliable_pub_sub.max_backlog_age (in secs) configurable (default to 7 days)
|
388
403
|
- Fix: API for MessageBus.backlog("/bla") was returning global backlog by mistake
|
389
404
|
- Change: Max global backlog size reduced to 2000 elements
|
390
405
|
|
391
406
|
08-06-2015
|
407
|
+
|
392
408
|
- Version 1.0.14
|
393
409
|
- Fix: we can not use Thread#kill best keepalive can do is terminate process cleanly
|
394
410
|
- Feature: you can opt-out of keepalive with MessageBus.keepalive_timeout = 0
|
395
411
|
|
396
412
|
08-06-2015
|
413
|
+
|
397
414
|
- Version 1.0.13
|
398
415
|
- Fix: on global subscribe reconnect replay missed messages
|
399
416
|
- Feature: keepalive tests for global subscribe, catches hung redis connections
|
400
417
|
|
401
418
|
28-05-2015
|
419
|
+
|
402
420
|
- Version 1.0.12
|
403
421
|
- Feature: Support client_id targeted message
|
404
422
|
|
405
423
|
06-05-2015
|
424
|
+
|
406
425
|
- Version 1.0.11
|
407
426
|
- Fix: race condition in TimerThread
|
408
427
|
|
409
428
|
01-05-2015
|
429
|
+
|
410
430
|
- Version: 1.0.10
|
411
431
|
- Feature: no longer depends on EventMachine (only used for Thin backend)
|
412
432
|
- Feature: reliable pub sub will queue messages in memory if redis is readonly, configurable
|
413
433
|
- Fix: if redis is flushed we will continue to deliver messages
|
414
434
|
|
415
435
|
23-03-2015
|
436
|
+
|
416
437
|
- Version 1.0.9
|
417
438
|
- Fix: inherit off StandardError not Exception for all exceptions raised
|
418
439
|
|
419
440
|
20-03-2015
|
441
|
+
|
420
442
|
- Version 1.0.8
|
421
443
|
- Fix: aggressive short polling in background
|
422
444
|
|
423
445
|
16-03-2015
|
446
|
+
|
424
447
|
- Version 1.0.7
|
425
448
|
- Feature: added pause and resume methods
|
426
449
|
|
427
450
|
03-02-2015
|
451
|
+
|
428
452
|
- Version 1.0.6
|
429
453
|
- Fix: global backlog not truncating correctly
|
430
454
|
|
431
455
|
23-09-2014
|
456
|
+
|
432
457
|
- Version 1.0.5
|
433
458
|
- Fix: missing custom headers from long polls
|
434
459
|
|
435
460
|
23-09-2014
|
461
|
+
|
436
462
|
- Version 1.0.4
|
437
463
|
- Change: MessageBus.access_control_allow_origin_lookup to extra_response_headers_lookup
|
438
464
|
|
439
465
|
23-09-2014
|
466
|
+
|
440
467
|
- Version 1.0.3
|
441
468
|
- Change: MessageBus.access_control_allow_origin to MessageBus.access_control_allow_origin_lookup
|
442
469
|
|
443
470
|
23-09-2014
|
471
|
+
|
444
472
|
- Version 1.0.2
|
445
473
|
- Feature: MessageBus.access_control_allow_origin to control origin header
|
446
474
|
|
447
475
|
23-09-2014
|
476
|
+
|
448
477
|
- Version 1.0.1
|
449
478
|
- Feature: $.ajax dependency can be passed in.
|
450
479
|
- Feature: unsubscribe accepts a second param for the function to unsubscribe.
|
451
480
|
|
452
481
|
22-09-2014
|
482
|
+
|
453
483
|
- Version 1.0.0
|
454
484
|
- Feature: add backgroundCallbackInterval - interval to send polls when page is in the background
|
455
485
|
- Feature: issue a long poll as soon as page moves into the foreground
|
456
486
|
|
457
487
|
11-08-2014
|
488
|
+
|
458
489
|
- Version 0.9.5
|
459
490
|
- Fix: release db connection a lot earlier for long polling (rails defer closes)
|
460
491
|
|
461
492
|
13-01-2014
|
493
|
+
|
462
494
|
- Version 0.9.4
|
463
495
|
- Added support for /global/ channel to publish messages across a multisite
|
464
496
|
- Cleaned up test harness so it uses local bus as opposed to global
|
@@ -467,19 +499,23 @@
|
|
467
499
|
- ensure_reactor could say the reactor is running, but it was not, on first call
|
468
500
|
|
469
501
|
06-12-2013
|
502
|
+
|
470
503
|
- Version 0.9.3.2
|
471
504
|
- Fix permissions in gem
|
472
505
|
|
473
506
|
05-12-2013
|
507
|
+
|
474
508
|
- Version 0.9.3.1
|
475
509
|
- Add MessageBus.diagnostics() for diagnosing bus issues client side
|
476
510
|
- Add more robustness to JavaScript, if callbacks used to fail they would halt the chain
|
477
511
|
|
478
512
|
03-12-2013
|
513
|
+
|
479
514
|
- Version 0.9.3
|
480
515
|
- Remove thin dependency
|
481
516
|
- Improve robustness under failure conditions
|
482
517
|
|
483
518
|
30-09-2013
|
519
|
+
|
484
520
|
- Fix failures in Ruby 1.9
|
485
521
|
- Set up rack hijack by default in light of passengers new setting
|
data/README.md
CHANGED
@@ -26,15 +26,21 @@ MessageBus only support officially supported versions of Ruby; as of [2021-03-31
|
|
26
26
|
|
27
27
|
Add this line to your application's Gemfile:
|
28
28
|
|
29
|
-
|
29
|
+
```ruby
|
30
|
+
gem 'message_bus'
|
31
|
+
```
|
30
32
|
|
31
33
|
And then execute:
|
32
34
|
|
33
|
-
|
35
|
+
```shell
|
36
|
+
$ bundle
|
37
|
+
```
|
34
38
|
|
35
39
|
Or install it yourself as:
|
36
40
|
|
37
|
-
|
41
|
+
```shell
|
42
|
+
$ gem install message_bus
|
43
|
+
```
|
38
44
|
|
39
45
|
## Usage
|
40
46
|
|
@@ -109,7 +115,7 @@ MessageBus.user_id_lookup do |env|
|
|
109
115
|
end
|
110
116
|
```
|
111
117
|
|
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
|
118
|
+
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.
|
113
119
|
|
114
120
|
```ruby
|
115
121
|
MessageBus.publish "/channel", "hello", user_ids: [1, 2, 3], group_ids: [1, 2, 3]
|
@@ -129,7 +135,7 @@ Custom client message filters can be registered via `MessageBus#register_client_
|
|
129
135
|
|
130
136
|
For example, ensuring that only messages seen by the server in the last 20 seconds are published to the client:
|
131
137
|
|
132
|
-
```
|
138
|
+
```ruby
|
133
139
|
MessageBus.register_client_message_filter('/test') do |message|
|
134
140
|
(Time.now.to_i - message.data[:published_at]) <= 20
|
135
141
|
end
|
@@ -280,7 +286,7 @@ MessageBus.start(); // call once at startup
|
|
280
286
|
MessageBus.callbackInterval = 500;
|
281
287
|
|
282
288
|
// you will get all new messages sent to channel
|
283
|
-
MessageBus.subscribe("/channel", function(data){
|
289
|
+
MessageBus.subscribe("/channel", function (data) {
|
284
290
|
// data shipped from server
|
285
291
|
});
|
286
292
|
|
@@ -386,6 +392,16 @@ headers|{}|Extra headers to be include with requests. Properties and values of o
|
|
386
392
|
|
387
393
|
message_bus can be configured to use one of several available storage backends, and each has its own configuration options.
|
388
394
|
|
395
|
+
### Keepalive
|
396
|
+
|
397
|
+
To ensure correct operation of message_bus, every 60 seconds a message is broadcast to itself. If for any reason the message is not consumed by the same process within 3 keepalive intervals a warning log message is raised.
|
398
|
+
|
399
|
+
To control keepalive interval use
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
MessageBus.configure(keepalive_interval: 60)
|
403
|
+
```
|
404
|
+
|
389
405
|
### Redis
|
390
406
|
|
391
407
|
message_bus supports using Redis as a storage backend, and you can configure message_bus to use redis in `config/initializers/message_bus.rb`, like so:
|
@@ -435,7 +451,6 @@ MessageBus.configure(backend: :memory)
|
|
435
451
|
|
436
452
|
The `:clear_every` option supported by the PostgreSQL backend is also supported by the in-memory backend.
|
437
453
|
|
438
|
-
|
439
454
|
### Transport codecs
|
440
455
|
|
441
456
|
By default MessageBus serializes messages to the backend using JSON. Under most situation this performs extremely well.
|
@@ -456,7 +471,7 @@ Keep in mind, much of MessageBus internals and supporting tools expect data to b
|
|
456
471
|
|
457
472
|
Another example may be very large and complicated messages where Oj in compatibility mode outperforms JSON. To opt for the Oj codec use:
|
458
473
|
|
459
|
-
```
|
474
|
+
```ruby
|
460
475
|
MessageBus.configure(transport_codec: MessageBus::Codec::Oj.new)
|
461
476
|
```
|
462
477
|
|
@@ -503,7 +518,6 @@ For more information see the [Passenger documentation](https://www.phusionpassen
|
|
503
518
|
|
504
519
|
```ruby
|
505
520
|
# path/to/your/config/puma.rb
|
506
|
-
require 'message_bus' # omit this line for Rails 5
|
507
521
|
on_worker_boot do
|
508
522
|
MessageBus.after_fork
|
509
523
|
end
|
@@ -513,7 +527,6 @@ end
|
|
513
527
|
|
514
528
|
```ruby
|
515
529
|
# path/to/your/config/unicorn.rb
|
516
|
-
require 'message_bus'
|
517
530
|
after_fork do |server, worker|
|
518
531
|
MessageBus.after_fork
|
519
532
|
end
|
@@ -554,26 +567,21 @@ MessageBus ships with an optional `DistributedCache` API which provides a simple
|
|
554
567
|
require 'message_bus/distributed_cache'
|
555
568
|
|
556
569
|
# process 1
|
557
|
-
|
558
570
|
cache = MessageBus::DistributedCache.new("animals")
|
559
571
|
|
560
572
|
# process 2
|
561
|
-
|
562
573
|
cache = MessageBus::DistributedCache.new("animals")
|
563
574
|
|
564
575
|
# process 1
|
565
|
-
|
566
576
|
cache["frogs"] = 5
|
567
577
|
|
568
578
|
# process 2
|
569
|
-
|
570
579
|
puts cache["frogs"]
|
571
580
|
# => 5
|
572
581
|
|
573
582
|
cache["frogs"] = nil
|
574
583
|
|
575
584
|
# process 1
|
576
|
-
|
577
585
|
puts cache["frogs"]
|
578
586
|
# => nil
|
579
587
|
```
|
@@ -631,7 +639,7 @@ In e.g. `config/initializers/message_bus.rb`:
|
|
631
639
|
```ruby
|
632
640
|
MessageBus.extra_response_headers_lookup do |env|
|
633
641
|
[
|
634
|
-
|
642
|
+
["Access-Control-Allow-Origin", "http://example.com:3000"],
|
635
643
|
]
|
636
644
|
end
|
637
645
|
```
|
@@ -692,8 +700,8 @@ In certain conditions, a status message will be delivered and look like this:
|
|
692
700
|
"message_id": -1,
|
693
701
|
"channel": "/__status",
|
694
702
|
"data": {
|
695
|
-
"/some/channel":5,
|
696
|
-
"/other/channel":9
|
703
|
+
"/some/channel": 5,
|
704
|
+
"/other/channel": 9
|
697
705
|
}
|
698
706
|
}
|
699
707
|
```
|
@@ -727,7 +735,7 @@ When submitting a PR, please be sure to include notes on it in the `Unreleased`
|
|
727
735
|
|
728
736
|
To run tests you need both Postgres and Redis installed. By default on Redis the tests connect to `localhost:6379` and on Postgres connect the database `localhost:5432/message_bus_test` with the system username; if you wish to override this, you can set alternative values:
|
729
737
|
|
730
|
-
```
|
738
|
+
```shell
|
731
739
|
PGUSER=some_user PGDATABASE=some_db bundle exec rake
|
732
740
|
```
|
733
741
|
|
data/Rakefile
CHANGED
@@ -5,18 +5,16 @@ require 'bundler'
|
|
5
5
|
require 'bundler/gem_tasks'
|
6
6
|
require 'bundler/setup'
|
7
7
|
require 'rubocop/rake_task'
|
8
|
+
require 'yard'
|
8
9
|
|
9
|
-
|
10
|
+
Bundler.require(:default, :test)
|
10
11
|
|
11
|
-
|
12
|
+
RuboCop::RakeTask.new
|
12
13
|
YARD::Rake::YardocTask.new
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
Bundler.require(:default, :test)
|
15
|
+
BACKENDS = Dir["lib/message_bus/backends/*.rb"].map { |file| file.match(%r{backends/(?<backend>.*).rb})[:backend] } - ["base"]
|
16
|
+
SPEC_FILES = Dir['spec/**/*_spec.rb']
|
17
|
+
INTEGRATION_FILES = Dir['spec/integration/**/*_spec.rb']
|
20
18
|
|
21
19
|
module CustomBuild
|
22
20
|
def build_gem
|
@@ -31,6 +29,11 @@ module Bundler
|
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
32
|
+
desc "Generate documentation for Yard, and fail if there are any warnings"
|
33
|
+
task :test_doc do
|
34
|
+
sh "yard --fail-on-warning #{'--no-progress' if ENV['CI']}"
|
35
|
+
end
|
36
|
+
|
34
37
|
namespace :jasmine do
|
35
38
|
desc "Run Jasmine tests in headless mode"
|
36
39
|
task 'ci' do
|
@@ -40,18 +43,16 @@ namespace :jasmine do
|
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
|
-
backends = Dir["lib/message_bus/backends/*.rb"].map { |file| file.match(%r{backends/(?<backend>.*).rb})[:backend] } - ["base"]
|
44
|
-
|
45
46
|
namespace :spec do
|
46
|
-
|
47
|
-
integration_files = Dir['spec/integration/**/*_spec.rb']
|
48
|
-
|
49
|
-
backends.each do |backend|
|
47
|
+
BACKENDS.each do |backend|
|
50
48
|
desc "Run tests on the #{backend} backend"
|
51
49
|
task backend do
|
52
50
|
begin
|
53
51
|
ENV['MESSAGE_BUS_BACKEND'] = backend
|
54
|
-
|
52
|
+
Rake::TestTask.new(backend) do |t|
|
53
|
+
t.test_files = SPEC_FILES - INTEGRATION_FILES
|
54
|
+
end
|
55
|
+
Rake::Task[backend].invoke
|
55
56
|
ensure
|
56
57
|
ENV.delete('MESSAGE_BUS_BACKEND')
|
57
58
|
end
|
@@ -74,7 +75,10 @@ namespace :spec do
|
|
74
75
|
ENV['MESSAGE_BUS_BACKEND'] = 'memory'
|
75
76
|
pid = spawn("bundle exec puma -p 9292 spec/fixtures/test/config.ru")
|
76
77
|
sleep 1 while port_available?(9292)
|
77
|
-
|
78
|
+
Rake::TestTask.new(:integration) do |t|
|
79
|
+
t.test_files = INTEGRATION_FILES
|
80
|
+
end
|
81
|
+
Rake::Task[:integration].invoke
|
78
82
|
ensure
|
79
83
|
ENV.delete('MESSAGE_BUS_BACKEND')
|
80
84
|
Process.kill('TERM', pid) if pid
|
@@ -83,12 +87,12 @@ namespace :spec do
|
|
83
87
|
end
|
84
88
|
|
85
89
|
desc "Run tests on all backends, plus client JS tests"
|
86
|
-
task spec:
|
90
|
+
task spec: BACKENDS.map { |backend| "spec:#{backend}" } + ["jasmine:ci", "spec:integration"]
|
87
91
|
|
88
92
|
desc "Run performance benchmarks on all backends"
|
89
93
|
task :performance do
|
90
94
|
begin
|
91
|
-
ENV['MESSAGE_BUS_BACKENDS'] =
|
95
|
+
ENV['MESSAGE_BUS_BACKENDS'] = BACKENDS.join(",")
|
92
96
|
sh "#{FileUtils::RUBY} -e \"ARGV.each{|f| load f}\" #{Dir['spec/performance/*.rb'].to_a.join(' ')}"
|
93
97
|
ensure
|
94
98
|
ENV.delete('MESSAGE_BUS_BACKENDS')
|
@@ -97,7 +101,3 @@ end
|
|
97
101
|
|
98
102
|
desc "Run all tests, link checks and confirms documentation compiles without error"
|
99
103
|
task default: [:spec, :rubocop, :test_doc]
|
100
|
-
|
101
|
-
Rake::Task['release'].enhance do
|
102
|
-
sh "yarn publish"
|
103
|
-
end
|
data/lib/message_bus/version.rb
CHANGED
data/lib/message_bus.rb
CHANGED
@@ -744,34 +744,11 @@ module MessageBus::Implementation
|
|
744
744
|
if !@destroyed && thread.alive? && keepalive_interval > MIN_KEEPALIVE
|
745
745
|
|
746
746
|
publish("/__mb_keepalive__/", Process.pid, user_ids: [-1])
|
747
|
-
# going for x3 keepalives missed for a restart, need to ensure this only very rarely happens
|
748
|
-
# note: after_fork will sort out a bad @last_message date, but thread will be dead anyway
|
749
747
|
if (Time.now - (@last_message || Time.now)) > keepalive_interval * 3
|
750
|
-
logger.warn "Global messages on #{Process.pid} timed out,
|
751
|
-
# No other clean way to remove this thread, its listening on a socket
|
752
|
-
# no data is arriving
|
753
|
-
#
|
754
|
-
# In production we see this kind of situation ... sometimes ... when there is
|
755
|
-
# a VRRP failover, or weird networking condition
|
756
|
-
pid = Process.pid
|
757
|
-
|
758
|
-
# do the best we can to terminate self cleanly
|
759
|
-
fork do
|
760
|
-
Process.kill('TERM', pid)
|
761
|
-
sleep 10
|
762
|
-
begin
|
763
|
-
Process.kill('KILL', pid)
|
764
|
-
rescue Errno::ESRCH
|
765
|
-
logger.warn "#{Process.pid} successfully terminated by `TERM` signal."
|
766
|
-
end
|
767
|
-
end
|
768
|
-
|
769
|
-
sleep 10
|
770
|
-
Process.kill('KILL', pid)
|
771
|
-
|
772
|
-
else
|
773
|
-
timer.queue(keepalive_interval, &blk) if keepalive_interval > MIN_KEEPALIVE
|
748
|
+
logger.warn "Global messages on #{Process.pid} timed out, message bus is no longer functioning correctly"
|
774
749
|
end
|
750
|
+
|
751
|
+
timer.queue(keepalive_interval, &blk) if keepalive_interval > MIN_KEEPALIVE
|
775
752
|
end
|
776
753
|
end
|
777
754
|
|
@@ -52,10 +52,6 @@ describe MessageBus::TimerThread do
|
|
52
52
|
it "should call the error callback if something goes wrong" do
|
53
53
|
error = nil
|
54
54
|
|
55
|
-
@timer.queue do
|
56
|
-
boom
|
57
|
-
end
|
58
|
-
|
59
55
|
@timer.on_error do |e|
|
60
56
|
error = e
|
61
57
|
end
|
@@ -64,7 +60,7 @@ describe MessageBus::TimerThread do
|
|
64
60
|
boom
|
65
61
|
end
|
66
62
|
|
67
|
-
wait_for(
|
63
|
+
wait_for(100) do
|
68
64
|
error
|
69
65
|
end
|
70
66
|
|
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.
|
4
|
+
version: 3.4.0
|
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: 2021-12-
|
11
|
+
date: 2021-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -362,7 +362,7 @@ homepage: https://github.com/discourse/message_bus
|
|
362
362
|
licenses:
|
363
363
|
- MIT
|
364
364
|
metadata: {}
|
365
|
-
post_install_message:
|
365
|
+
post_install_message:
|
366
366
|
rdoc_options: []
|
367
367
|
require_paths:
|
368
368
|
- lib
|
@@ -377,8 +377,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
377
377
|
- !ruby/object:Gem::Version
|
378
378
|
version: '0'
|
379
379
|
requirements: []
|
380
|
-
rubygems_version: 3.
|
381
|
-
signing_key:
|
380
|
+
rubygems_version: 3.3.3
|
381
|
+
signing_key:
|
382
382
|
specification_version: 4
|
383
383
|
summary: ''
|
384
384
|
test_files:
|