message_bus 3.4.0 → 4.0.0
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 +1 -8
- data/CHANGELOG +9 -1
- data/README.md +4 -34
- data/docker-compose.yml +1 -1
- data/lib/message_bus/backends/postgres.rb +1 -0
- data/lib/message_bus/backends/redis.rb +3 -0
- data/lib/message_bus/rack/middleware.rb +0 -6
- data/lib/message_bus/version.rb +1 -1
- data/lib/message_bus.rb +34 -46
- data/spec/lib/message_bus/backend_spec.rb +3 -3
- data/spec/lib/message_bus/multi_process_spec.rb +2 -2
- data/spec/lib/message_bus/rack/middleware_spec.rb +0 -48
- data/spec/lib/message_bus_spec.rb +10 -2
- data/spec/performance/publish.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- metadata +6 -14
- data/assets/application.jsx +0 -121
- data/assets/babel.min.js +0 -25
- data/assets/react-dom.js +0 -19851
- data/assets/react.js +0 -3029
- data/examples/diagnostics/Gemfile +0 -6
- data/examples/diagnostics/config.ru +0 -22
- data/lib/message_bus/diagnostics.rb +0 -62
- data/lib/message_bus/rack/diagnostics.rb +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65630299cab9aae5df5b4f3131043d42063575978d5a83e9267436bed2b7d729
|
4
|
+
data.tar.gz: 2bd69d120552b01ae82c73a775d065c23575ac623016d2bd2ac25a5ebd637d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a5d250126fc935053dfffef037baaf780678764ac95e4924603b901016f82b451a79a51f18fc699f2cfd8006cb805cd4887d206c12ca68ac68f059f1f13409
|
7
|
+
data.tar.gz: 2ebcc465985827a16866a948690a7bb4c03252050c8bfb1ee458809c6f0eda8c8fd581ba2f9bb1b496d3c7952456a11ad6ac51dd63e69c465238cffa17d7c2da
|
data/.eslintrc.js
CHANGED
@@ -10,12 +10,5 @@ module.exports = {
|
|
10
10
|
sourceType: 'module',
|
11
11
|
},
|
12
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
|
-
],
|
13
|
+
ignorePatterns: ['/vendor', '/doc', '/assets/jquery-1.8.2.js'],
|
21
14
|
};
|
data/CHANGELOG
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
11-01-2022
|
2
|
+
|
3
|
+
- Version 4.0.0
|
4
|
+
|
5
|
+
- DEV: Remove backend diagnostics
|
6
|
+
- DEV: Rename reliable_pub_sub to backend_instance
|
7
|
+
- FIX: `destroy` following `after_fork` could thread lock
|
8
|
+
|
1
9
|
31-12-2021
|
2
10
|
|
3
11
|
- Version 3.4.0
|
4
12
|
|
5
|
-
|
13
|
+
- FEATURE: Remove process auto-termination on missed keepalives
|
6
14
|
|
7
15
|
20-12-2021
|
8
16
|
|
data/README.md
CHANGED
@@ -169,32 +169,6 @@ curl -H "Content-Type: application/x-www-form-urlencoded" -X POST --data "/messa
|
|
169
169
|
|
170
170
|
You should see a reply with the messages of that channel you requested (in this case `/message`) starting at the message ID you requested (`0`). The URL parameter `dlp=t` disables long-polling: we do not want this request to stay open.
|
171
171
|
|
172
|
-
### Diagnostics
|
173
|
-
|
174
|
-
MessageBus comes with a diagnostics interface, which you can access at `/message-bus/_diagnostics`. This interface allows you visibility into the runtime behaviour of message_bus.
|
175
|
-
|
176
|
-
In order to use the diagnostics UI in your application, it is necessary to:
|
177
|
-
|
178
|
-
* Enable it
|
179
|
-
* Define a user ID for requests
|
180
|
-
* Define a check for admin role
|
181
|
-
|
182
|
-
as an example, you can do something like this:
|
183
|
-
|
184
|
-
```ruby
|
185
|
-
MessageBus.enable_diagnostics # Must be called after `MessageBus.after_fork` if using a forking webserver
|
186
|
-
|
187
|
-
MessageBus.user_id_lookup do |_env|
|
188
|
-
1
|
189
|
-
end
|
190
|
-
|
191
|
-
MessageBus.is_admin_lookup do |_env|
|
192
|
-
true
|
193
|
-
end
|
194
|
-
```
|
195
|
-
|
196
|
-
Of course, in your real-world application, you would define these values according to your authentication/authorization logic.
|
197
|
-
|
198
172
|
### Transport
|
199
173
|
|
200
174
|
MessageBus ships with 3 transport mechanisms.
|
@@ -416,17 +390,17 @@ The redis client message_bus uses is [redis-rb](https://github.com/redis/redis-r
|
|
416
390
|
|
417
391
|
Out of the box Redis keeps track of 2000 messages in the global backlog and 1000 messages in a per-channel backlog. Per-channel backlogs get cleared automatically after 7 days of inactivity.
|
418
392
|
|
419
|
-
This is configurable via accessors on the
|
393
|
+
This is configurable via accessors on the Backend instance.
|
420
394
|
|
421
395
|
```ruby
|
422
396
|
# only store 100 messages per channel
|
423
|
-
MessageBus.
|
397
|
+
MessageBus.backend_instance.max_backlog_size = 100
|
424
398
|
|
425
399
|
# only store 100 global messages
|
426
|
-
MessageBus.
|
400
|
+
MessageBus.backend_instance.max_global_backlog_size = 100
|
427
401
|
|
428
402
|
# flush per-channel backlog after 100 seconds of inactivity
|
429
|
-
MessageBus.
|
403
|
+
MessageBus.backend_instance.max_backlog_age = 100
|
430
404
|
```
|
431
405
|
|
432
406
|
### PostgreSQL
|
@@ -750,7 +724,3 @@ While working on documentation, it is useful to automatically re-build it as you
|
|
750
724
|
### Benchmarks
|
751
725
|
|
752
726
|
Some simple benchmarks are implemented in `spec/performance` and can be executed using `rake performance` (or `docker-compose run tests rake performance`). You should run these before and after your changes to avoid introducing performance regressions.
|
753
|
-
|
754
|
-
### Diagnostics Interface
|
755
|
-
|
756
|
-
It is possible to manually test the diagnostics interface by executing `docker-compose up example` and then `open http://localhost:9292`.
|
data/docker-compose.yml
CHANGED
@@ -36,7 +36,7 @@ services:
|
|
36
36
|
example:
|
37
37
|
build:
|
38
38
|
context: .
|
39
|
-
command: bash -c "cd examples/
|
39
|
+
command: bash -c "cd examples/chat && bundle install && bundle exec rackup --server puma --host 0.0.0.0"
|
40
40
|
environment:
|
41
41
|
BUNDLE_TO: /usr/local/bundle
|
42
42
|
REDISURL: redis://redis:6379
|
@@ -59,6 +59,7 @@ module MessageBus
|
|
59
59
|
@lock = Mutex.new
|
60
60
|
@flush_backlog_thread = nil
|
61
61
|
@pub_redis = nil
|
62
|
+
@subscribed = false
|
62
63
|
# after 7 days inactive backlogs will be removed
|
63
64
|
@max_backlog_age = 604800
|
64
65
|
end
|
@@ -260,6 +261,7 @@ LUA
|
|
260
261
|
new_redis.publish(redis_channel_name, UNSUB_MESSAGE)
|
261
262
|
ensure
|
262
263
|
new_redis&.disconnect!
|
264
|
+
@subscribed = false
|
263
265
|
end
|
264
266
|
end
|
265
267
|
|
@@ -302,6 +304,7 @@ LUA
|
|
302
304
|
|
303
305
|
on.message do |_c, m|
|
304
306
|
if m == UNSUB_MESSAGE
|
307
|
+
@subscribed = false
|
305
308
|
global_redis.unsubscribe
|
306
309
|
return
|
307
310
|
end
|
@@ -41,7 +41,6 @@ class MessageBus::Rack::Middleware
|
|
41
41
|
@started_listener = false
|
42
42
|
@base_route = "#{@bus.base_route}message-bus/"
|
43
43
|
@base_route_length = @base_route.length
|
44
|
-
@diagnostics_route = "#{@base_route}_diagnostics"
|
45
44
|
@broadcast_route = "#{@base_route}broadcast"
|
46
45
|
start_listener unless @bus.off?
|
47
46
|
end
|
@@ -79,11 +78,6 @@ class MessageBus::Rack::Middleware
|
|
79
78
|
return [200, { "Content-Type" => "text/html" }, ["sent"]]
|
80
79
|
end
|
81
80
|
|
82
|
-
if env['PATH_INFO'].start_with? @diagnostics_route
|
83
|
-
diags = MessageBus::Rack::Diagnostics.new(@app, message_bus: @bus)
|
84
|
-
return diags.call(env)
|
85
|
-
end
|
86
|
-
|
87
81
|
client_id = env['PATH_INFO'][@base_route_length..-1].split("/")[0]
|
88
82
|
return [404, {}, ["not found"]] unless client_id
|
89
83
|
|
data/lib/message_bus/version.rb
CHANGED
data/lib/message_bus.rb
CHANGED
@@ -7,9 +7,7 @@ require_relative "message_bus/version"
|
|
7
7
|
require_relative "message_bus/message"
|
8
8
|
require_relative "message_bus/client"
|
9
9
|
require_relative "message_bus/connection_manager"
|
10
|
-
require_relative "message_bus/diagnostics"
|
11
10
|
require_relative "message_bus/rack/middleware"
|
12
|
-
require_relative "message_bus/rack/diagnostics"
|
13
11
|
require_relative "message_bus/timer_thread"
|
14
12
|
require_relative "message_bus/codec/base"
|
15
13
|
require_relative "message_bus/backends"
|
@@ -47,21 +45,6 @@ module MessageBus::Implementation
|
|
47
45
|
@subscriber_thread = nil
|
48
46
|
end
|
49
47
|
|
50
|
-
# @param [Boolean] val whether or not to cache static assets for the diagnostics pages
|
51
|
-
# @return [void]
|
52
|
-
def cache_assets=(val)
|
53
|
-
configure(cache_assets: val)
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [Boolean] whether or not to cache static assets for the diagnostics pages
|
57
|
-
def cache_assets
|
58
|
-
if defined? @config[:cache_assets]
|
59
|
-
@config[:cache_assets]
|
60
|
-
else
|
61
|
-
true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
48
|
# @param [Logger] logger a logger object to be used by the bus
|
66
49
|
# @return [void]
|
67
50
|
def logger=(logger)
|
@@ -297,15 +280,20 @@ module MessageBus::Implementation
|
|
297
280
|
@config[:transport_codec] ||= MessageBus::Codec::Json.new
|
298
281
|
end
|
299
282
|
|
300
|
-
# @param [MessageBus::Backend::Base]
|
283
|
+
# @param [MessageBus::Backend::Base] backend_instance A configured backend
|
301
284
|
# @return [void]
|
285
|
+
def backend_instance=(backend_instance)
|
286
|
+
configure(backend_instance: backend_instance)
|
287
|
+
end
|
288
|
+
|
302
289
|
def reliable_pub_sub=(pub_sub)
|
303
|
-
|
290
|
+
logger.warn "MessageBus.reliable_pub_sub= is deprecated, use MessageBus.backend_instance= instead."
|
291
|
+
self.backend_instance = pub_sub
|
304
292
|
end
|
305
293
|
|
306
294
|
# @return [MessageBus::Backend::Base] the configured backend. If not
|
307
295
|
# explicitly set, will be loaded based on the configuration provided.
|
308
|
-
def
|
296
|
+
def backend_instance
|
309
297
|
@mutex.synchronize do
|
310
298
|
return nil if @destroyed
|
311
299
|
|
@@ -313,7 +301,7 @@ module MessageBus::Implementation
|
|
313
301
|
# passed to backend.
|
314
302
|
logger
|
315
303
|
|
316
|
-
@config[:
|
304
|
+
@config[:backend_instance] ||= begin
|
317
305
|
@config[:backend_options] ||= {}
|
318
306
|
require "message_bus/backends/#{backend}"
|
319
307
|
MessageBus::BACKENDS[backend].new @config
|
@@ -321,17 +309,16 @@ module MessageBus::Implementation
|
|
321
309
|
end
|
322
310
|
end
|
323
311
|
|
312
|
+
def reliable_pub_sub
|
313
|
+
logger.warn "MessageBus.reliable_pub_sub is deprecated, use MessageBus.backend_instance instead."
|
314
|
+
backend_instance
|
315
|
+
end
|
316
|
+
|
324
317
|
# @return [Symbol] the name of the backend implementation configured
|
325
318
|
def backend
|
326
319
|
@config[:backend] || :redis
|
327
320
|
end
|
328
321
|
|
329
|
-
# Enables diagnostics tracking
|
330
|
-
# @return [void]
|
331
|
-
def enable_diagnostics
|
332
|
-
MessageBus::Diagnostics.enable(self)
|
333
|
-
end
|
334
|
-
|
335
322
|
# Publishes a message to a channel
|
336
323
|
#
|
337
324
|
# @param [String] channel the name of the channel to which the message should be published
|
@@ -398,7 +385,7 @@ module MessageBus::Implementation
|
|
398
385
|
end
|
399
386
|
|
400
387
|
encoded_channel_name = encode_channel_name(channel, site_id)
|
401
|
-
|
388
|
+
backend_instance.publish(encoded_channel_name, encoded_data, channel_opts)
|
402
389
|
end
|
403
390
|
|
404
391
|
# Subscribe to messages. Each message will be delivered by yielding to the
|
@@ -414,9 +401,9 @@ module MessageBus::Implementation
|
|
414
401
|
# @return [void]
|
415
402
|
def blocking_subscribe(channel = nil, &blk)
|
416
403
|
if channel
|
417
|
-
|
404
|
+
backend_instance.subscribe(encode_channel_name(channel), &blk)
|
418
405
|
else
|
419
|
-
|
406
|
+
backend_instance.global_subscribe(&blk)
|
420
407
|
end
|
421
408
|
end
|
422
409
|
|
@@ -495,9 +482,9 @@ module MessageBus::Implementation
|
|
495
482
|
def backlog(channel = nil, last_id = nil, site_id = nil)
|
496
483
|
old =
|
497
484
|
if channel
|
498
|
-
|
485
|
+
backend_instance.backlog(encode_channel_name(channel, site_id), last_id)
|
499
486
|
else
|
500
|
-
|
487
|
+
backend_instance.global_backlog(last_id)
|
501
488
|
end
|
502
489
|
|
503
490
|
old.each do |m|
|
@@ -513,7 +500,7 @@ module MessageBus::Implementation
|
|
513
500
|
#
|
514
501
|
# @return [Integer] the channel-specific ID of the last message published to the given channel
|
515
502
|
def last_id(channel, site_id = nil)
|
516
|
-
|
503
|
+
backend_instance.last_id(encode_channel_name(channel, site_id))
|
517
504
|
end
|
518
505
|
|
519
506
|
# Get the last message published on a channel
|
@@ -536,8 +523,8 @@ module MessageBus::Implementation
|
|
536
523
|
def destroy
|
537
524
|
return if @destroyed
|
538
525
|
|
539
|
-
|
540
|
-
|
526
|
+
backend_instance.global_unsubscribe
|
527
|
+
backend_instance.destroy
|
541
528
|
|
542
529
|
@mutex.synchronize do
|
543
530
|
return if @destroyed
|
@@ -555,7 +542,7 @@ module MessageBus::Implementation
|
|
555
542
|
# scheduled tasks.
|
556
543
|
# @return [void]
|
557
544
|
def after_fork
|
558
|
-
|
545
|
+
backend_instance.after_fork
|
559
546
|
ensure_subscriber_thread
|
560
547
|
# will ensure timer is running
|
561
548
|
timer.queue {}
|
@@ -564,12 +551,12 @@ module MessageBus::Implementation
|
|
564
551
|
# @return [Boolean] whether or not the server is actively listening for
|
565
552
|
# publications on the bus
|
566
553
|
def listening?
|
567
|
-
@subscriber_thread
|
554
|
+
@subscriber_thread&.alive?
|
568
555
|
end
|
569
556
|
|
570
557
|
# (see MessageBus::Backend::Base#reset!)
|
571
558
|
def reset!
|
572
|
-
|
559
|
+
backend_instance.reset! if backend_instance
|
573
560
|
end
|
574
561
|
|
575
562
|
# @return [MessageBus::TimerThread] the timer thread used for triggering
|
@@ -697,12 +684,6 @@ module MessageBus::Implementation
|
|
697
684
|
@subscriptions[site_id][channel] << blk
|
698
685
|
ensure_subscriber_thread
|
699
686
|
|
700
|
-
attempts = 100
|
701
|
-
while attempts > 0 && !reliable_pub_sub.subscribed
|
702
|
-
sleep 0.001
|
703
|
-
attempts -= 1
|
704
|
-
end
|
705
|
-
|
706
687
|
raise MessageBus::BusDestroyed if @destroyed
|
707
688
|
|
708
689
|
blk
|
@@ -720,10 +701,17 @@ module MessageBus::Implementation
|
|
720
701
|
|
721
702
|
def ensure_subscriber_thread
|
722
703
|
@mutex.synchronize do
|
723
|
-
return if
|
704
|
+
return if @destroyed
|
705
|
+
next if @subscriber_thread&.alive?
|
724
706
|
|
725
707
|
@subscriber_thread = new_subscriber_thread
|
726
708
|
end
|
709
|
+
|
710
|
+
attempts = 100
|
711
|
+
while attempts > 0 && !backend_instance.subscribed
|
712
|
+
sleep 0.001
|
713
|
+
attempts -= 1
|
714
|
+
end
|
727
715
|
end
|
728
716
|
|
729
717
|
MIN_KEEPALIVE = 20
|
@@ -760,7 +748,7 @@ module MessageBus::Implementation
|
|
760
748
|
def global_subscribe_thread
|
761
749
|
# pretend we just got a message
|
762
750
|
@last_message = Time.now
|
763
|
-
|
751
|
+
backend_instance.global_subscribe do |msg|
|
764
752
|
begin
|
765
753
|
@last_message = Time.now
|
766
754
|
decode_message!(msg)
|
@@ -3,9 +3,9 @@
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
require 'message_bus'
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe BACKEND_CLASS do
|
7
7
|
before do
|
8
|
-
@bus =
|
8
|
+
@bus = BACKEND_CLASS.new(test_config_for_backend(CURRENT_BACKEND))
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
@@ -30,7 +30,7 @@ describe PUB_SUB_CLASS do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should initialize with max_backlog_size" do
|
33
|
-
|
33
|
+
BACKEND_CLASS.new({}, 2000).max_backlog_size.must_equal 2000
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should truncate channels correctly" do
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
require 'message_bus'
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe BACKEND_CLASS do
|
7
7
|
def self.error!
|
8
8
|
@error = true
|
9
9
|
end
|
@@ -13,7 +13,7 @@ describe PUB_SUB_CLASS do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def new_bus
|
16
|
-
|
16
|
+
BACKEND_CLASS.new(test_config_for_backend(CURRENT_BACKEND).merge(db: 10))
|
17
17
|
end
|
18
18
|
|
19
19
|
def work_it
|
@@ -142,54 +142,6 @@ describe MessageBus::Rack::Middleware do
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
describe "diagnostics" do
|
146
|
-
it "should return a 403 if an unauthorized user attempts to get at the _diagnostics path" do
|
147
|
-
get "/message-bus/_diagnostics"
|
148
|
-
last_response.status.must_equal 403
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should get a 200 with html for an authorized user" do
|
152
|
-
def @bus.is_admin_lookup
|
153
|
-
proc { |_| true }
|
154
|
-
end
|
155
|
-
|
156
|
-
get "/message-bus/_diagnostics"
|
157
|
-
last_response.status.must_equal 200
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "with an altered base_route" do
|
161
|
-
let(:base_route) { "/base/route/" }
|
162
|
-
|
163
|
-
it "should get a 200 with html for an authorized user" do
|
164
|
-
def @bus.is_admin_lookup
|
165
|
-
proc { |_| true }
|
166
|
-
end
|
167
|
-
|
168
|
-
get "/base/route/message-bus/_diagnostics"
|
169
|
-
last_response.status.must_equal 200
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should get the script it asks for" do
|
174
|
-
def @bus.is_admin_lookup
|
175
|
-
proc { |_| true }
|
176
|
-
end
|
177
|
-
|
178
|
-
get "/message-bus/_diagnostics/assets/message-bus.js"
|
179
|
-
last_response.status.must_equal 200
|
180
|
-
last_response.content_type.must_equal "application/javascript;charset=UTF-8"
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should return 404 for invalid assets path" do
|
184
|
-
def @bus.is_admin_lookup
|
185
|
-
proc { |_| true }
|
186
|
-
end
|
187
|
-
|
188
|
-
get "/message-bus/_diagnostics/assets/../Gemfile"
|
189
|
-
last_response.status.must_equal 404
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
145
|
describe "polling" do
|
194
146
|
before do
|
195
147
|
@bus.long_polling_enabled = false
|
@@ -37,6 +37,14 @@ describe MessageBus do
|
|
37
37
|
@bus.after_fork
|
38
38
|
end
|
39
39
|
|
40
|
+
it "destroying immediately after `after_fork` does not lock" do
|
41
|
+
10.times do
|
42
|
+
@bus.on
|
43
|
+
@bus.after_fork
|
44
|
+
@bus.destroy
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
40
48
|
describe "#base_route=" do
|
41
49
|
it "adds leading and trailing slashes" do
|
42
50
|
@bus.base_route = "my/base/route"
|
@@ -107,7 +115,7 @@ describe MessageBus do
|
|
107
115
|
@bus.publish("/chuck", norris: true)
|
108
116
|
@bus.publish("/chuck", norris: true)
|
109
117
|
|
110
|
-
@bus.
|
118
|
+
@bus.backend_instance.reset!
|
111
119
|
|
112
120
|
@bus.publish("/chuck", yeager: true)
|
113
121
|
|
@@ -125,7 +133,7 @@ describe MessageBus do
|
|
125
133
|
@bus.publish("/chuck", norris: true)
|
126
134
|
@bus.publish("/chuck", norris: true)
|
127
135
|
|
128
|
-
@bus.
|
136
|
+
@bus.backend_instance.expire_all_backlogs!
|
129
137
|
|
130
138
|
@bus.publish("/chuck", yeager: true)
|
131
139
|
|
data/spec/performance/publish.rb
CHANGED
@@ -32,8 +32,8 @@ benchmark_subscription_no_trimming = lambda do |bm, backend|
|
|
32
32
|
bus = MessageBus::Instance.new
|
33
33
|
bus.configure(test_config_for_backend(backend))
|
34
34
|
|
35
|
-
bus.
|
36
|
-
bus.
|
35
|
+
bus.backend_instance.max_backlog_size = iterations
|
36
|
+
bus.backend_instance.max_global_backlog_size = iterations
|
37
37
|
|
38
38
|
messages_received = 0
|
39
39
|
bus.after_fork
|
@@ -58,8 +58,8 @@ benchmark_subscription_with_trimming = lambda do |bm, backend|
|
|
58
58
|
bus = MessageBus::Instance.new
|
59
59
|
bus.configure(test_config_for_backend(backend))
|
60
60
|
|
61
|
-
bus.
|
62
|
-
bus.
|
61
|
+
bus.backend_instance.max_backlog_size = (iterations / 10)
|
62
|
+
bus.backend_instance.max_global_backlog_size = (iterations / 10)
|
63
63
|
|
64
64
|
messages_received = 0
|
65
65
|
bus.after_fork
|
data/spec/spec_helper.rb
CHANGED
@@ -14,7 +14,7 @@ require_relative "helpers"
|
|
14
14
|
CURRENT_BACKEND = (ENV['MESSAGE_BUS_BACKEND'] || :redis).to_sym
|
15
15
|
|
16
16
|
require "message_bus/backends/#{CURRENT_BACKEND}"
|
17
|
-
|
17
|
+
BACKEND_CLASS = MessageBus::BACKENDS.fetch(CURRENT_BACKEND)
|
18
18
|
|
19
19
|
puts "Running with backend: #{CURRENT_BACKEND}"
|
20
20
|
|
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:
|
4
|
+
version: 4.0.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:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -282,13 +282,9 @@ files:
|
|
282
282
|
- LICENSE
|
283
283
|
- README.md
|
284
284
|
- Rakefile
|
285
|
-
- assets/application.jsx
|
286
|
-
- assets/babel.min.js
|
287
285
|
- assets/jquery-1.8.2.js
|
288
286
|
- assets/message-bus-ajax.js
|
289
287
|
- assets/message-bus.js
|
290
|
-
- assets/react-dom.js
|
291
|
-
- assets/react.js
|
292
288
|
- bench/codecs/all_codecs.rb
|
293
289
|
- bench/codecs/marshal.rb
|
294
290
|
- bench/codecs/packed_string.rb
|
@@ -306,8 +302,6 @@ files:
|
|
306
302
|
- examples/chat/config.ru
|
307
303
|
- examples/chat/docker_container/chat.yml
|
308
304
|
- examples/chat/docker_container/update_chat
|
309
|
-
- examples/diagnostics/Gemfile
|
310
|
-
- examples/diagnostics/config.ru
|
311
305
|
- examples/minimal/Gemfile
|
312
306
|
- examples/minimal/config.ru
|
313
307
|
- lib/message_bus.rb
|
@@ -321,13 +315,11 @@ files:
|
|
321
315
|
- lib/message_bus/codec/json.rb
|
322
316
|
- lib/message_bus/codec/oj.rb
|
323
317
|
- lib/message_bus/connection_manager.rb
|
324
|
-
- lib/message_bus/diagnostics.rb
|
325
318
|
- lib/message_bus/distributed_cache.rb
|
326
319
|
- lib/message_bus/http_client.rb
|
327
320
|
- lib/message_bus/http_client/channel.rb
|
328
321
|
- lib/message_bus/http_client/version.rb
|
329
322
|
- lib/message_bus/message.rb
|
330
|
-
- lib/message_bus/rack/diagnostics.rb
|
331
323
|
- lib/message_bus/rack/middleware.rb
|
332
324
|
- lib/message_bus/rack/thin_ext.rb
|
333
325
|
- lib/message_bus/rails/railtie.rb
|
@@ -362,7 +354,7 @@ homepage: https://github.com/discourse/message_bus
|
|
362
354
|
licenses:
|
363
355
|
- MIT
|
364
356
|
metadata: {}
|
365
|
-
post_install_message:
|
357
|
+
post_install_message:
|
366
358
|
rdoc_options: []
|
367
359
|
require_paths:
|
368
360
|
- lib
|
@@ -377,8 +369,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
377
369
|
- !ruby/object:Gem::Version
|
378
370
|
version: '0'
|
379
371
|
requirements: []
|
380
|
-
rubygems_version: 3.
|
381
|
-
signing_key:
|
372
|
+
rubygems_version: 3.1.6
|
373
|
+
signing_key:
|
382
374
|
specification_version: 4
|
383
375
|
summary: ''
|
384
376
|
test_files:
|