Skip to content
CAI
Software that uses CAICheck a score

discourse/message_bus

39.1

Weak · 19 September 2026

12.3k

lines of production code

JavaScript

with Ruby

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Ruby-based message bus library that facilitates real-time, bidirectional communication between servers and clients using long-polling and chunked encoding. It supports multiple storage backends, including Redis, PostgreSQL, and an in-memory option, while providing a distributed cache for synchronizing state across application instances. The library includes a modernized JavaScript client for browser-side subscriptions and a Ruby HTTP client for server-side polling, all integrated via standard Rack middleware compatible with various web servers.

How it got here

2013 — MessageBus 5.0 modernization

11 changes.

This period focused on upgrading MessageBus to version 5.0, introducing a new HTTP client, distributed cache, and granular client permissions while removing legacy dependencies on EventMachine and jQuery. The project also standardized its development environment with Docker and linting, migrated the test suite to Minitest, and modernized JavaScript build tools.

2014–2016 — backend expansion and test coverage

7 changes.

This period focused on expanding the MessageBus library's capabilities by introducing a new in-memory backend and configurable message codecs. Significant effort was dedicated to comprehensive test coverage, adding suites for core backends, clients, Rack middleware, and JavaScript assets to ensure stability and correctness.

2018–2026 — Performance benchmarking and test coverage expansion

5 changes.

This period focused on enhancing test coverage and performance evaluation by adding integration tests for the HTTP client and fixtures for the Rack middleware. It also introduced comprehensive benchmarking suites for backlog operations, message publishing, and custom serialization codecs to measure throughput across different backends and strategies.

Features

Add Docker container example for Message Bus chat service

Introduces a new Docker container configuration for the Message Bus chat example, including a YAML definition and an update script. The setup provisions a Redis instance, clones the Message Bus repository, and runs the application using the Pitchfork web server. It configures Nginx to handle HTTPS traffic on port 443 with specific SSL protocols and ciphers, proxying requests to the backend, and includes an update script to pull new code and rebuild the container.

_examples/chat/docker\container · high confidence

Add chat demo with presence tracking and session timeouts

The chat example now includes a basic presence system that tracks online users and automatically removes sessions that have timed out (after 5 minutes of inactivity). The demo also implements XSS protection by sanitizing user input before rendering messages in the browser.

examples/chat · high confidence

Add minimal Rack application example

A new minimal example application has been added to the examples/minimal directory, providing a basic Rack setup using MessageBus. This entry point demonstrates how to configure the MessageBus Rack middleware and run a simple HTTP response, serving as a starting reference for integrating the library into a Rack-based environment.

examples/minimal · high confidence

Added benchmark suite for custom transport codecs

A new benchmarking suite has been added to the \bench\ directory to evaluate the performance of various serialization strategies. This includes implementations for JSON, Oj, Ruby Marshal, a custom PackedString codec (with 4-byte and 8-byte integer packing), and a StringHack codec. The suite provides scripts to benchmark decoding performance on both standard messages and large user lists, allowing users to compare throughput across different encoding methods.

bench · high confidence

Added benchmarking example for MessageBus

A new benchmarking setup has been added to the examples/bench directory to help users evaluate MessageBus performance. This includes a wrk Lua script (bench.lua) configured to simulate long-polling traffic while handling specific HTTP constraints like chunking and connection closing, along with configuration files for Puma, Unicorn, and Rack (config.ru) that initialize MessageBus with specific long-polling intervals and client limits. A sample command (wrk.sample) is also provided to demonstrate how to run the benchmark against a local instance.

examples/bench · high confidence

MessageBus 5.0.0 introduces HTTP client, distributed cache, and refined client permissions

This release upgrades the library to version 5.0.0 and introduces a new Ruby HTTP client (MessageBus::HTTPClient) that supports long polling and chunked encoding for server-side subscriptions. It adds a DistributedCache system to keep hash-like data synchronized across multiple application instances. Client permissions are now more granular, supporting group-based filtering via the \intersect?\ method and allowing messages to be targeted at specific clients. The internal architecture is refactored to use a \TimerThread\ for scheduling, and legacy components like \Diagnostics\ and \MessageHandler\ are removed.

_lib/message\bus · high confidence

New memory backend and configurable message codecs

The message bus now includes a new in-memory backend (Memory) for environments that do not require persistent storage, alongside the existing Redis and PostgreSQL backends. Additionally, the system now supports custom message codecs, allowing users to choose between the standard JSON encoder and the faster Oj encoder for serializing and deserializing message payloads.

_lib/message\bus/backends · high confidence

Standardized development environment with linting, Docker, and automated testing

The project now includes configuration files for ESLint and Prettier to standardize JavaScript formatting, and a RuboCop configuration inheriting from Discourse's style guide for Ruby code. A Dockerfile and docker-compose.yml have been added to containerize the application, providing pre-configured Redis and PostgreSQL services for local development and testing. The Rakefile has been significantly expanded to automatically generate and run tests for all supported backends (Redis, PostgreSQL, Memory), integrate Jasmine client-side tests, and enforce documentation quality via YARD.

(repo-wide) · high confidence

Behavioural changes

MessageBus JavaScript client rewritten with UMD support and jQuery decoupling

The MessageBus JavaScript client has been completely rewritten to remove the hard dependency on jQuery, replacing it with a native XMLHttpRequest-based AJAX adapter (message-bus-ajax.js) that serves as a fallback. The client now supports AMD, CommonJS, and UMD module formats, allowing it to be used in modern build environments or as a global script. The diagnostics UI has been migrated from an Ember.js application to React, and the underlying polling mechanism has been enhanced with features like chunked encoding support, visibility-based backoff for hidden tabs, and improved error handling.

assets · high confidence

MessageBus middleware now inserts before Flash and supports API-only mode

The MessageBus middleware is now inserted before ActionDispatch::Flash in standard Rails applications to ensure the session is available when processing messages, and it defaults to using \use\ in API-only mode. This change also introduces a \skip\_message\_bus\_middleware\ configuration option to allow users to opt out of the middleware registration if needed.

_lib/message\bus/rails · high confidence

MessageBus refactored to use centralized configuration and updated defaults

The MessageBus library has been refactored to replace individual instance variables with a centralized \@config\ hash managed via a new \configure\ method, improving consistency and thread safety. This change introduces several default value adjustments: the long-polling interval is now 25 seconds (previously 30 seconds), Rack Hijack is enabled by default (unless restricted by Passenger configuration), and the maximum number of active clients defaults to 1000. Additionally, the library now requires \monitor\ for synchronization and updates the Rails integration to check for \Rails::Engine\ instead of just \Rails\.

lib · high confidence

Removes diagnostics UI and decouples MessageBus from EventMachine

The legacy diagnostics interface (lib/message\_bus/rack/diagnostics.rb) has been removed, eliminating the embedded Ember.js-based debug UI. Additionally, the middleware no longer depends on EventMachine or the Thin async adapter (lib/message\_bus/rack/thin\_ext.rb); it now uses standard Rack polling and long-polling mechanisms, making the library compatible with non-EventMachine servers like Puma.

_lib/message\bus/rack · high confidence

Test coverage

Added comprehensive test suite for Message Bus backends and clients; Added integration tests for the Ruby MessageBus HTTP client; Added performance benchmarks for backlog and publish operations; Added test fixture for MessageBus Rack middleware; Added test suite for MessageBus Rack middleware; Added test suite for MessageBus core functionality; Added tests for asset encoding and presence; Migrate test suite from RSpec to Minitest; Migrate test suite to Minitest and modernize test infrastructure.

Dependencies

Add support for testing against Rack 2 and Rack 3

The project now includes dedicated Gemfiles (rack2.gemfile and rack3.gemfile) that pin the Rack dependency to versions 2.x and 3.x respectively. This enables the library to be tested against both major versions of Rack, ensuring compatibility across different environments.

gemfiles · high confidence

Modernizes Ruby and JavaScript dependency management

The project updates its dependency structure by requiring Ruby 3.3.0 and restricting the Rack dependency to versions 2 and 3, while moving test-specific gems like Redis, Thin, and Minitest to development-only dependencies in the gemspec. For the JavaScript client, it introduces a new package.json with pnpm as the package manager and adds ESLint, Jasmine, and Jasmine Browser Runner as dev dependencies, establishing a modern build and linting workflow for the frontend assets.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 39.

Lenses

  • Code Health 79
  • Architecture 100
  • Maturity 62
  • Readiness 41
  • Security 67
  • Accessibility 20

Changes since last survey

  • 300 commits — 233 feature/other, 67 fixes

By area

  • (root) — 146 commits
  • lib/message_bus — 76 commits
  • spec/lib — 30 commits
  • .github/workflows — 14 commits
  • lib/message_bus.rb — 11 commits
  • (repo) — 8 commits
  • assets/message-bus.js — 7 commits
  • assets/message-bus-ajax.js — 3 commits
  • spec/helpers.rb — 2 commits
  • bench/codecs — 1 commit
  • spec/assets — 1 commit
  • spec/performance — 1 commit

Notable commits

  • fix: DEV: Downgrade puma to fix the build (#369)
  • fix: DEV: Fix ESLint errors (#264)
  • fix: DEV: Fix Rubocop runs on Github Actions (#241)
  • fix: DEV: Fix a spec assertion (#272)
  • fix: DEV: Fix an incorrect Rails check (#271)
  • fix: DEV: Fix another warning and enable verbose specs (#298)
  • fix: DEV: Fix broken rubocop rules
  • fix: DEV: Fix integration specs (#275)
  • fix: DEV: Fix linting (#353)
  • fix: DEV: Fix logger usage in backend specs (#265)
  • fix: DEV: Fix ruby warnings (#286)
  • fix: DEV: Various spec fixes (#290)
  • fix: FIX: Add Redis 5 support
  • fix: FIX: Avoid leaking Redis connections. (#229)
  • fix: FIX: Code adjustment to unfreeze strings
  • fix: FIX: Disconnect Redis conn when rescuing errors in global subscribe.
  • fix: FIX: Do not disable chunking on cancel/error (#325)
  • fix: FIX: Don't error when trying to write a message to a closed client (#336)
  • fix: FIX: Don't publish message to intersection of user_ids and group_ids
  • fix: FIX: Ensure non-long-polling requests are always spaced out (#324)
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

discourse/message_bus was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit b43f68d8ff779460e7440d05a4bc608e3f3d1711 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.