message_bus 4.4.1 → 4.5.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/.github/workflows/ci.yml +31 -10
- data/.gitignore +0 -2
- data/CHANGELOG +7 -0
- data/README.md +5 -3
- data/Rakefile +2 -2
- data/docker-compose.yml +1 -1
- data/examples/bench/config.ru +1 -1
- data/examples/chat/Gemfile +1 -1
- data/examples/chat/docker_container/chat.yml +3 -3
- data/examples/minimal/config.ru +1 -1
- data/lib/message_bus/connection_manager.rb +7 -2
- data/lib/message_bus/rack/middleware.rb +5 -5
- data/lib/message_bus/version.rb +1 -1
- data/message_bus.gemspec +3 -2
- data/package.json +8 -1
- data/pnpm-lock.yaml +1526 -0
- data/spec/fixtures/test/config.ru +1 -1
- data/spec/integration/http_client_spec.rb +1 -1
- data/spec/lib/message_bus/client_spec.rb +1 -1
- data/spec/lib/message_bus/connection_manager_spec.rb +23 -0
- metadata +23 -10
- data/DEV.md +0 -7
- data/package-lock.json +0 -3781
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0191a3cefe09aba3cbad0048cb6dd56ed1e9d05159ac66f26429715f3e785d6
|
|
4
|
+
data.tar.gz: bcdcb1b72f53eb15c220ca4909de5ceadb251678a174d16f3e277934bf72802d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47ee3632a6eca276a1eacb3ddde8f5e56b36d11d30ea8414756338e6a0baec6f6d609cc7a1bc2c9d86561d6d9f1c2347a2e1f912cf3a519fb1c842b9e83aab06
|
|
7
|
+
data.tar.gz: da53d5bb3626d27f9b8236c31064496f085c09486149d584b17aee86ac7ed58d1809c9b8c4f7151fe986b9d83dd89d26761cc878b2e6feb27de3d6b4c1de7530
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -19,20 +19,22 @@ jobs:
|
|
|
19
19
|
ruby-version: "3.3"
|
|
20
20
|
bundler-cache: true
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
|
|
22
|
+
- uses: pnpm/action-setup@v4
|
|
23
|
+
|
|
24
|
+
- uses: actions/setup-node@v6
|
|
24
25
|
with:
|
|
25
|
-
node-version:
|
|
26
|
-
cache:
|
|
26
|
+
node-version: "24"
|
|
27
|
+
cache: "pnpm"
|
|
27
28
|
|
|
28
|
-
- name:
|
|
29
|
-
run:
|
|
29
|
+
- name: Pnpm install
|
|
30
|
+
run: pnpm install
|
|
30
31
|
|
|
31
32
|
- name: Rubocop
|
|
32
33
|
run: bundle exec rubocop
|
|
33
34
|
|
|
34
35
|
- name: ESLint
|
|
35
|
-
|
|
36
|
+
if: ${{ !cancelled() }}
|
|
37
|
+
run: pnpm lint
|
|
36
38
|
|
|
37
39
|
test:
|
|
38
40
|
runs-on: ubuntu-latest
|
|
@@ -77,6 +79,16 @@ jobs:
|
|
|
77
79
|
ruby-version: ${{ matrix.ruby }}
|
|
78
80
|
bundler-cache: true
|
|
79
81
|
|
|
82
|
+
- uses: pnpm/action-setup@v4
|
|
83
|
+
|
|
84
|
+
- uses: actions/setup-node@v6
|
|
85
|
+
with:
|
|
86
|
+
node-version: "24"
|
|
87
|
+
cache: "pnpm"
|
|
88
|
+
|
|
89
|
+
- name: Pnpm install
|
|
90
|
+
run: pnpm install
|
|
91
|
+
|
|
80
92
|
- name: Tests
|
|
81
93
|
env:
|
|
82
94
|
TESTOPTS: --verbose
|
|
@@ -87,6 +99,10 @@ jobs:
|
|
|
87
99
|
needs: [lint, test]
|
|
88
100
|
runs-on: ubuntu-latest
|
|
89
101
|
|
|
102
|
+
permissions:
|
|
103
|
+
id-token: write
|
|
104
|
+
contents: write
|
|
105
|
+
|
|
90
106
|
steps:
|
|
91
107
|
- uses: actions/checkout@v4
|
|
92
108
|
|
|
@@ -108,8 +124,13 @@ jobs:
|
|
|
108
124
|
git add package.json
|
|
109
125
|
git commit -m 'bump'
|
|
110
126
|
|
|
127
|
+
- uses: pnpm/action-setup@v4
|
|
128
|
+
|
|
129
|
+
- uses: actions/setup-node@v6
|
|
130
|
+
with:
|
|
131
|
+
node-version: "24"
|
|
132
|
+
cache: "pnpm"
|
|
133
|
+
|
|
111
134
|
- name: Publish package
|
|
112
|
-
uses: JS-DevTools/npm-publish@v3
|
|
113
135
|
if: steps.publish-gem.outputs.new_version == 'true'
|
|
114
|
-
|
|
115
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
136
|
+
run: pnpm publish -r
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A reliable, robust messaging bus for Ruby processes and web clients.
|
|
|
4
4
|
|
|
5
5
|
MessageBus implements a Server to Server channel based protocol and Server to Web Client protocol (using polling, long-polling or long-polling + streaming)
|
|
6
6
|
|
|
7
|
-
Since long-polling is implemented using Rack Hijack and Thin::Async, all common Ruby web servers (
|
|
7
|
+
Since long-polling is implemented using Rack Hijack and Thin::Async, all common Ruby web servers (Pitchfork/Unicorn, Puma, Thin, Passenger) can run MessageBus and handle a large number of concurrent connections that wait on messages.
|
|
8
8
|
|
|
9
9
|
MessageBus is implemented as Rack middleware and can be used by any Rails / Sinatra or pure Rack application.
|
|
10
10
|
|
|
@@ -381,7 +381,9 @@ MessageBus.configure(keepalive_interval: 60)
|
|
|
381
381
|
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:
|
|
382
382
|
|
|
383
383
|
```ruby
|
|
384
|
-
MessageBus.configure(backend: :redis,
|
|
384
|
+
MessageBus.configure(backend: :redis, redis_config: {
|
|
385
|
+
url: "redis://:p4ssw0rd@10.0.1.1:6380/15"
|
|
386
|
+
})
|
|
385
387
|
```
|
|
386
388
|
|
|
387
389
|
The redis client message_bus uses is [redis-rb](https://github.com/redis/redis-rb), so you can visit it's repo to see what other options you can pass besides a `url`.
|
|
@@ -502,7 +504,7 @@ on_worker_boot do
|
|
|
502
504
|
end
|
|
503
505
|
```
|
|
504
506
|
|
|
505
|
-
#### Unicorn
|
|
507
|
+
#### Pitchfork/Unicorn
|
|
506
508
|
|
|
507
509
|
```ruby
|
|
508
510
|
# path/to/your/config/unicorn.rb
|
data/Rakefile
CHANGED
|
@@ -35,7 +35,7 @@ end
|
|
|
35
35
|
namespace :jasmine do
|
|
36
36
|
desc "Run Jasmine tests in headless mode"
|
|
37
37
|
task 'ci' do
|
|
38
|
-
if !system("
|
|
38
|
+
if !system("pnpm jasmine-browser-runner runSpecs")
|
|
39
39
|
exit 1
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -71,7 +71,7 @@ namespace :spec do
|
|
|
71
71
|
|
|
72
72
|
begin
|
|
73
73
|
ENV['MESSAGE_BUS_BACKEND'] = 'memory'
|
|
74
|
-
pid = spawn("bundle exec
|
|
74
|
+
pid = spawn("bundle exec pitchfork -p 9292 spec/fixtures/test/config.ru")
|
|
75
75
|
sleep 1 while port_available?(9292)
|
|
76
76
|
Rake::TestTask.new(:integration) do |t|
|
|
77
77
|
t.test_files = INTEGRATION_FILES
|
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/chat && bundle install && bundle exec rackup --server
|
|
39
|
+
command: bash -c "cd examples/chat && bundle install && bundle exec rackup --server pitchfork --host 0.0.0.0"
|
|
40
40
|
environment:
|
|
41
41
|
BUNDLE_TO: /usr/local/bundle
|
|
42
42
|
REDISURL: redis://redis:6379
|
data/examples/bench/config.ru
CHANGED
|
@@ -30,4 +30,4 @@ end
|
|
|
30
30
|
MessageBus.long_polling_interval = 1000 * 2
|
|
31
31
|
MessageBus.max_active_clients = 10000
|
|
32
32
|
use MessageBus::Rack::Middleware
|
|
33
|
-
run lambda { |_env| [200, { "
|
|
33
|
+
run lambda { |_env| [200, { "content-type" => "text/html" }, ["Howdy"]] }
|
data/examples/chat/Gemfile
CHANGED
|
@@ -33,18 +33,18 @@ hooks:
|
|
|
33
33
|
- exec: cd /var/www && git clone --depth 1 https://github.com/SamSaffron/message_bus.git
|
|
34
34
|
- exec:
|
|
35
35
|
cmd:
|
|
36
|
-
- gem install
|
|
36
|
+
- gem install pitchfork
|
|
37
37
|
- gem install redis
|
|
38
38
|
- gem install sinatra
|
|
39
39
|
- file:
|
|
40
|
-
path: /etc/service/
|
|
40
|
+
path: /etc/service/pitchfork/run
|
|
41
41
|
chmod: "+x"
|
|
42
42
|
contents: |
|
|
43
43
|
#!/bin/bash
|
|
44
44
|
exec 2>&1
|
|
45
45
|
# redis
|
|
46
46
|
cd $home/examples/chat
|
|
47
|
-
exec sudo -E -u chat LD_PRELOAD=/usr/lib/libjemalloc.so.1
|
|
47
|
+
exec sudo -E -u chat LD_PRELOAD=/usr/lib/libjemalloc.so.1 pitchfork -p 8080 -e production
|
|
48
48
|
- exec: rm /etc/nginx/sites-enabled/default
|
|
49
49
|
- replace:
|
|
50
50
|
filename: /etc/nginx/nginx.conf
|
data/examples/minimal/config.ru
CHANGED
|
@@ -76,8 +76,13 @@ class MessageBus::ConnectionManager
|
|
|
76
76
|
def remove_client(c)
|
|
77
77
|
synchronize do
|
|
78
78
|
@clients.delete c.client_id
|
|
79
|
-
@subscriptions[c.site_id]
|
|
80
|
-
|
|
79
|
+
site_subs = @subscriptions[c.site_id]
|
|
80
|
+
if site_subs
|
|
81
|
+
site_subs.delete_if do |_k, set|
|
|
82
|
+
set.delete c.client_id
|
|
83
|
+
set.empty?
|
|
84
|
+
end
|
|
85
|
+
@subscriptions.delete(c.site_id) if site_subs.empty?
|
|
81
86
|
end
|
|
82
87
|
if c.cleanup_timer
|
|
83
88
|
# concurrency may cause this to fail
|
|
@@ -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|
|
|
@@ -131,7 +131,7 @@ class MessageBus::Rack::Middleware
|
|
|
131
131
|
env['QUERY_STRING'] !~ /dlp=t/ &&
|
|
132
132
|
@connection_manager.client_count < @bus.max_active_clients
|
|
133
133
|
|
|
134
|
-
allow_chunked = env['HTTP_VERSION'] == 'HTTP/1.1'
|
|
134
|
+
allow_chunked = env['SERVER_PROTOCOL'] == 'HTTP/1.1' || env['HTTP_VERSION'] == 'HTTP/1.1'
|
|
135
135
|
allow_chunked &&= !env['HTTP_DONT_CHUNK']
|
|
136
136
|
allow_chunked &&= @bus.chunked_encoding_enabled?
|
|
137
137
|
|
data/lib/message_bus/version.rb
CHANGED
data/message_bus.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
|
16
16
|
gem.version = MessageBus::VERSION
|
|
17
17
|
gem.required_ruby_version = ">= 2.6.0"
|
|
18
18
|
|
|
19
|
-
gem.add_runtime_dependency 'rack', '
|
|
19
|
+
gem.add_runtime_dependency 'rack', '~> 3'
|
|
20
20
|
|
|
21
21
|
# Optional runtime dependencies
|
|
22
22
|
gem.add_development_dependency 'redis'
|
|
@@ -30,9 +30,10 @@ Gem::Specification.new do |gem|
|
|
|
30
30
|
gem.add_development_dependency 'http_parser.rb'
|
|
31
31
|
gem.add_development_dependency 'thin'
|
|
32
32
|
gem.add_development_dependency 'rack-test'
|
|
33
|
-
gem.add_development_dependency '
|
|
33
|
+
gem.add_development_dependency 'pitchfork'
|
|
34
34
|
gem.add_development_dependency 'm'
|
|
35
35
|
gem.add_development_dependency 'byebug'
|
|
36
|
+
gem.add_development_dependency 'method_source'
|
|
36
37
|
gem.add_development_dependency 'oj'
|
|
37
38
|
gem.add_development_dependency 'yard'
|
|
38
39
|
|
data/package.json
CHANGED
|
@@ -19,9 +19,16 @@
|
|
|
19
19
|
"url": "https://github.com/discourse/message_bus/issues"
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/discourse/message_bus#readme",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"lint": "eslint ."
|
|
27
|
+
},
|
|
22
28
|
"devDependencies": {
|
|
23
29
|
"eslint": "^8.31.0",
|
|
24
30
|
"jasmine-browser-runner": "^0.10.0",
|
|
25
31
|
"jasmine-core": "^3.10.1"
|
|
26
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"packageManager": "pnpm@9.15.5"
|
|
27
34
|
}
|