message_bus 4.3.1 → 4.3.3
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/CHANGELOG +13 -2
- data/README.md +3 -8
- data/assets/message-bus.js +8 -4
- data/lib/message_bus/client.rb +1 -1
- data/lib/message_bus/rack/middleware.rb +4 -4
- data/lib/message_bus/version.rb +1 -1
- data/package-lock.json +573 -847
- data/spec/assets/SpecHelper.js +23 -5
- data/spec/assets/message-bus.spec.js +59 -0
- data/spec/lib/message_bus/client_spec.rb +6 -0
- data/vendor/assets/javascripts/message-bus.js +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b692999acb957ed29356cbe5611bc0e1227bf13af613523aea54782aea2983f
|
4
|
+
data.tar.gz: 14ac3f99c3155428caa990e40cc50d1a1ed35fafced96d8de88d6d982acb8dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5391f6c888f343f0d383745e0ac60390ad82b1666426ffbe6b8bac924e959ddb585bbc118a9cfdb713683b7ec1d38c2a7b3fbb53a7de9abf9e6a4b92e67b372d
|
7
|
+
data.tar.gz: c50d50cf2e443eb25d68e858b20a023c735b8c155231805d7cddea40fc4039c9be0a1e3704bcfe6adf1368de2a0760905329d1632b37e13636e990c79c4bcf1c
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
|
1
|
+
19-06-2023
|
2
|
+
|
3
|
+
- Version 4.3.3
|
4
|
+
|
5
|
+
- FIX: Use lowercase header names in `MessageBus::Rack::Middleware` for compatibility with Rack 3.x.
|
6
|
+
- FIX: Don't error when trying to write a message to a closed client
|
7
|
+
|
8
|
+
13-01-2023
|
9
|
+
|
10
|
+
- Version 4.3.2
|
11
|
+
|
12
|
+
- FIX: Do not disable chunking on cancel/error
|
2
13
|
|
3
14
|
06-01-2023
|
4
15
|
|
@@ -27,7 +38,7 @@ FUTURE
|
|
27
38
|
|
28
39
|
- PERF: Optimize Client#backlog for up-to-date clients
|
29
40
|
|
30
|
-
Also introduces a new MessageBus#last_ids(
|
41
|
+
Also introduces a new MessageBus#last_ids(\*channels) api for fetching the last_ids of
|
31
42
|
multiple channels simultaneously
|
32
43
|
|
33
44
|
11-01-2022
|
data/README.md
CHANGED
@@ -416,7 +416,7 @@ message_bus also supports PostgreSQL as a backend, and can be configured like so
|
|
416
416
|
MessageBus.configure(backend: :postgres, backend_options: {user: 'message_bus', dbname: 'message_bus'})
|
417
417
|
```
|
418
418
|
|
419
|
-
The PostgreSQL client message_bus uses is [ruby-pg](https://
|
419
|
+
The PostgreSQL client message_bus uses is [ruby-pg](https://github.com/ged/ruby-pg), so you can visit it's repo to see what options you can include in `:backend_options`.
|
420
420
|
|
421
421
|
A `:clear_every` option is also supported, which limits backlog trimming frequency to the specified number of publications. If you set `clear_every: 100`, the backlog will only be cleared every 100 publications. This can improve performance in cases where exact backlog length limiting is not required.
|
422
422
|
|
@@ -526,16 +526,11 @@ Rails.application.config do |config|
|
|
526
526
|
end
|
527
527
|
```
|
528
528
|
|
529
|
-
Specifically, if you use a Rack middleware-based authentication solution (such as Warden) in a Rails application and wish to use it for authenticating message_bus requests, you must ensure that the MessageBus middleware comes after it in the stack.
|
529
|
+
Specifically, if you use a Rack middleware-based authentication solution (such as Warden) in a Rails application and wish to use it for authenticating message_bus requests, you must ensure that the MessageBus middleware comes after it in the stack.
|
530
530
|
|
531
531
|
```ruby
|
532
532
|
# config/initializers/message_bus.rb
|
533
|
-
Rails.application.config
|
534
|
-
# See https://github.com/rails/rails/issues/26303#issuecomment-442894832
|
535
|
-
MyAppMessageBusMiddleware = Class.new(MessageBus::Rack::Middleware)
|
536
|
-
config.middleware.delete(MessageBus::Rack::Middleware)
|
537
|
-
config.middleware.insert_after(Warden::Manager, MyAppMessageBusMiddleware)
|
538
|
-
end
|
533
|
+
Rails.application.config.middleware.move_after(Warden::Manager, MessageBus::Rack::Middleware)
|
539
534
|
```
|
540
535
|
|
541
536
|
### A Distributed Cache
|
data/assets/message-bus.js
CHANGED
@@ -205,10 +205,11 @@
|
|
205
205
|
return handle_progress(payload, endChunk + separator.length);
|
206
206
|
};
|
207
207
|
|
208
|
+
var chunkedTimeout;
|
208
209
|
var disableChunked = function () {
|
209
210
|
if (me.longPoll) {
|
210
211
|
me.longPoll.abort();
|
211
|
-
chunkedBackoff =
|
212
|
+
chunkedBackoff = me.retryChunkedAfterRequests;
|
212
213
|
}
|
213
214
|
};
|
214
215
|
|
@@ -235,9 +236,9 @@
|
|
235
236
|
chunked: chunked,
|
236
237
|
onProgressListener: function (xhr) {
|
237
238
|
var position = 0;
|
238
|
-
// if it takes longer than
|
239
|
-
//
|
240
|
-
|
239
|
+
// if it takes longer than firstChunkTimeout to get first chunk, there may be a proxy
|
240
|
+
// buffering the response. Switch to non-chunked long-polling mode.
|
241
|
+
chunkedTimeout = setTimeout(disableChunked, me.firstChunkTimeout);
|
241
242
|
return (xhr.onprogress = function () {
|
242
243
|
clearTimeout(chunkedTimeout);
|
243
244
|
if (
|
@@ -269,6 +270,7 @@
|
|
269
270
|
}
|
270
271
|
},
|
271
272
|
error: function (xhr, textStatus) {
|
273
|
+
clearTimeout(chunkedTimeout);
|
272
274
|
if (xhr.status === 429) {
|
273
275
|
var tryAfter =
|
274
276
|
parseInt(
|
@@ -364,6 +366,8 @@
|
|
364
366
|
clientId: clientId,
|
365
367
|
alwaysLongPoll: false,
|
366
368
|
shouldLongPollCallback: undefined,
|
369
|
+
firstChunkTimeout: 3000,
|
370
|
+
retryChunkedAfterRequests: 30,
|
367
371
|
baseUrl: baseUrl,
|
368
372
|
headers: {},
|
369
373
|
ajax: typeof jQuery !== "undefined" && jQuery.ajax,
|
data/lib/message_bus/client.rb
CHANGED
@@ -82,10 +82,10 @@ class MessageBus::Rack::Middleware
|
|
82
82
|
return [404, {}, ["not found"]] unless client_id
|
83
83
|
|
84
84
|
headers = {}
|
85
|
-
headers["
|
86
|
-
headers["
|
87
|
-
headers["
|
88
|
-
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
89
|
|
90
90
|
if @bus.extra_response_headers_lookup
|
91
91
|
@bus.extra_response_headers_lookup.call(env).each do |k, v|
|
data/lib/message_bus/version.rb
CHANGED