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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4a55e419b6f5807f46429d27360a776c8c8057d663188f1911aca78cb6198fc
4
- data.tar.gz: dd96e8f87e10aca16262ca540997011871f0ba809a1153eb330aa82d8683267d
3
+ metadata.gz: c0191a3cefe09aba3cbad0048cb6dd56ed1e9d05159ac66f26429715f3e785d6
4
+ data.tar.gz: bcdcb1b72f53eb15c220ca4909de5ceadb251678a174d16f3e277934bf72802d
5
5
  SHA512:
6
- metadata.gz: b62eacf519bc544cde94ac05683938c2ca4c98bfaeaefd79e99ac012864d4c0ac20412ccc9fd0910cdf122b2883841af24339d299101b35e7296c0faa60c103f
7
- data.tar.gz: 44fb3cda5e137b61f35d5b0f1be204ab179594df59423948946ad4790b5b9bf3d8087be3aa55f819dfe9df6b65d3a30138312cc69a0726711bd65821789f459c
6
+ metadata.gz: 47ee3632a6eca276a1eacb3ddde8f5e56b36d11d30ea8414756338e6a0baec6f6d609cc7a1bc2c9d86561d6d9f1c2347a2e1f912cf3a519fb1c842b9e83aab06
7
+ data.tar.gz: da53d5bb3626d27f9b8236c31064496f085c09486149d584b17aee86ac7ed58d1809c9b8c4f7151fe986b9d83dd89d26761cc878b2e6feb27de3d6b4c1de7530
@@ -19,20 +19,22 @@ jobs:
19
19
  ruby-version: "3.3"
20
20
  bundler-cache: true
21
21
 
22
- - name: Set up Node.js
23
- uses: actions/setup-node@v4
22
+ - uses: pnpm/action-setup@v4
23
+
24
+ - uses: actions/setup-node@v6
24
25
  with:
25
- node-version: 20
26
- cache: npm
26
+ node-version: "24"
27
+ cache: "pnpm"
27
28
 
28
- - name: Setup npm
29
- run: npm install
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
- run: npx eslint .
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
- with:
115
- token: ${{ secrets.NPM_TOKEN }}
136
+ run: pnpm publish -r
data/.gitignore CHANGED
@@ -16,7 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  *.swp
19
- .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
20
19
  .byebug_history
21
20
  node_modules/
22
- yarn.lock
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 10-02-2026
2
+
3
+ - Version 4.5.0
4
+
5
+ - Support chunked encoding for Puma 7 on Rack 3.1
6
+ - FIX: Prune empty subscriptions in `ConnectionManager#remove_client`
7
+
1
8
  20-03-2025
2
9
 
3
10
  - Version 4.4.1
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 (Thin, Puma, Unicorn, Passenger) can run MessageBus and handle a large number of concurrent connections that wait on messages.
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, url: "redis://:p4ssw0rd@10.0.1.1:6380/15")
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("npx jasmine-browser-runner runSpecs")
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 puma -p 9292 spec/fixtures/test/config.ru")
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 puma --host 0.0.0.0"
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
@@ -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, { "Content-Type" => "text/html" }, ["Howdy"]] }
33
+ run lambda { |_env| [200, { "content-type" => "text/html" }, ["Howdy"]] }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
- gem 'puma'
2
+ gem 'pitchfork'
3
3
  gem 'redis'
4
4
  gem 'sinatra'
@@ -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 puma
36
+ - gem install pitchfork
37
37
  - gem install redis
38
38
  - gem install sinatra
39
39
  - file:
40
- path: /etc/service/puma/run
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 puma -p 8080 -e production
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
@@ -4,4 +4,4 @@ require 'message_bus'
4
4
  # MessageBus.long_polling_interval = 1000 * 2
5
5
 
6
6
  use MessageBus::Rack::Middleware
7
- run lambda { |_env| [200, { "Content-Type" => "text/html" }, ["Howdy"]] }
7
+ run lambda { |_env| [200, { "content-type" => "text/html" }, ["Howdy"]] }
@@ -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].each do |_k, set|
80
- set.delete c.client_id
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["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"
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MessageBus
4
- VERSION = "4.4.1"
4
+ VERSION = "4.5.0"
5
5
  end
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', '>= 1.1.3'
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 'puma'
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
  }