MCPcopy Index your code
hub / github.com/centrifugal/centrifugo

github.com/centrifugal/centrifugo @v6.8.4 sqlite

repository ↗ · DeepWiki ↗ · release v6.8.4 ↗
5,266 symbols 15,709 edges 352 files 1,526 documented · 29%
README

Centrifugo

Scalable real-time messaging server in a language-agnostic way.

CI Release Go Report Card Docker Pulls License Telegram Discord

Centrifugo is an open-source scalable real-time messaging server. It instantly delivers messages to application online users connected over supported transports (WebSocket, HTTP-streaming, Server-Sent Events (aka EventSource), GRPC, WebTransport). Centrifugo has the concept of channel subscriptions – so it's a user-facing PUB/SUB server.

Centrifugo is language-agnostic and can be used to build chat apps, live comments, multiplayer games, real-time data visualizations, collaborative tools, AI streaming responses, etc. in combination with any backend. It is well suited for modern architectures and allows decoupling the business logic from the real-time transport layer.

The core idea of Centrifugo is simple – it's a PUB/SUB server on top of modern real-time transports:

Centrifugo PUB/SUB diagram

Your backend communicates with Centrifugo over a simple HTTP or GRPC API to publish messages into channels, while clients subscribe to those channels using one of the official SDKs (or the unidirectional approach with no SDK dependency).

Quick start

Spin up Centrifugo with its embedded admin UI using Docker:

docker run -it --rm -p 8000:8000 centrifugo/centrifugo:latest centrifugo \
  --client.insecure --admin.enabled --admin.insecure
# ^ insecure flags: for local trial only, never use in production

Then open http://localhost:8000 to reach the admin UI, where you can watch live connections and publish messages into channels. The insecure flags above remove authentication for a frictionless local trial only – never use them in production.

For native binaries, Homebrew, packages, and production configuration see the installation instructions, and follow the quickstart tutorial to connect your first client.

Why Centrifugo

The hard part is to make the PUB/SUB concept production-ready, efficient, flexible and available from different application environments. Centrifugo is a mature solution that already helped many projects with adding real-time features and scaling towards many concurrent connections. It provides a set of features not available in other open-source solutions in the area:

  • Efficient real-time transports: WebSocket, HTTP-streaming, Server-Sent Events, GRPC, WebTransport (experimental)
  • Built-in scalability with Redis (or Redis Cluster, or Redis-compatible storage – ex. AWS Elasticache, Valkey, KeyDB, DragonflyDB, etc), PostgreSQL or Nats.
  • Simple HTTP and GRPC server API to communicate with Centrifugo from the app backend
  • Asynchronous PostgreSQL and Kafka consumers to support transactional outbox and CDC patterns
  • Flexible connection authentication mechanisms: JWT and proxy-like (via request from Centrifugo to the backend)
  • Channel subscription multiplexing over a single connection
  • Rich subscription model: stream (client-side and server-side), map, shared poll, and proxy subscription streams
  • Various channel permission strategies, channel namespace concept
  • Hot message history in channels, with automatic message recovery upon reconnect, cache recovery mode (deliver latest publication immediately upon subscription)
  • Delta compression in channels based on Fossil algorithm
  • Online channel presence information, with join/leave notifications
  • A way to send RPC calls to the backend over the real-time connection
  • Strict and effective client protocol wrapped by several official SDKs
  • JSON and binary Protobuf message transfer, with optimized serialization and built-in batching
  • Beautiful embedded admin web UI
  • Great observability with lots of Prometheus metrics exposed and official Grafana dashboard
  • And much more, visit Centrifugo documentation site

Client SDKs

Official SDKs wrap Centrifugo's bidirectional protocol and handle reconnects, subscription state, message recovery, and more across platforms:

Platform / Language SDK
JavaScript (browser, Node.js, React Native) centrifuge-js
Dart / Flutter (mobile and web) centrifuge-dart
Swift / native iOS centrifuge-swift
Java (Android, JVM) centrifuge-java
Python (asyncio) centrifuge-python
Go centrifuge-go
.NET / MAUI / Unity [WIP] centrifuge-csharp

For simple use cases Centrifugo also supports a unidirectional approach (WebSocket, SSE, HTTP-streaming, GRPC) that needs no SDK – any standard client for the transport works. See the transports overview and the client protocol spec for details.

Documentation

Community

Found a bug or have an idea? Open an issue. Want to contribute? See CONTRIBUTING.md.

Backing

This repository is hosted by packagecloud.io.

Private NPM registry and Maven, RPM, DEB, PyPi and RubyGem Repository · packagecloud

Also thanks to JetBrains for supporting OSS (most of the code here written in Goland):

JetBrains logo

Extension points exported contracts — how you extend this code

SurveyCaller (Interface)
SurveyCaller can do surveys. [6 implementers]
internal/api/api.go
PubSub (Interface)
PubSub provides lightweight publish/subscribe on a single channel. Used for shared poll notifications — not for general- [6 …
internal/pubsub/pubsub.go
Service (Interface)
(no doc) [16 implementers]
internal/service/service.go
Decoder (Interface)
Decoder has the same semantics as Setter, but takes higher precedence. It is provided for historical compatibility. [3 …
internal/config/envconfig/envconfig.go
ResultEncoder (Interface)
ResultEncoder ... [2 implementers]
internal/apiproto/encode.go
SubRefreshProxy (Interface)
SubRefreshProxy allows to send sub refresh requests. [2 implementers]
internal/proxy/sub_refresh.go
Client (Interface)
Client represents client connection. [1 implementers]
internal/client/client.go
BufferPool (Interface)
BufferPool represents a pool of buffers. The *sync.Pool type satisfies this interface. The type of the value stored in a [1 …
internal/websocket/conn.go

Core symbols most depended-on inside this repo

Close
called by 305
internal/pubsub/pubsub.go
Err
called by 303
internal/uniws/cancelctx.go
Error
called by 263
internal/apiproto/errors.go
Run
called by 243
internal/service/service.go
Error
called by 224
internal/config/envconfig/envconfig.go
Add
called by 155
internal/jwks/cache.go
Exec
called by 138
internal/pgschema/pgschema.go
Shutdown
called by 128
internal/redisqueue/consumer.go

Shape

Method 3,152
Function 1,391
Struct 639
Interface 40
TypeAlias 23
FuncType 21

Languages

Go100%
TypeScript1%

Modules by API surface

internal/apiproto/api.pb.go1,493 symbols
internal/proxyproto/proxy.pb.go496 symbols
internal/apiproto/api_grpc.pb.go211 symbols
internal/unigrpc/unistream/unistream.pb.go150 symbols
internal/configtypes/types.go89 symbols
internal/pgmapbroker/pgmapbroker_test.go80 symbols
internal/proxyproto/proxy_grpc.pb.go76 symbols
internal/websocket/conn.go67 symbols
internal/pgmapbroker/pgmapbroker.go67 symbols
internal/config/envconfig/envconfig_test.go55 symbols
internal/consuming/kafka_test.go53 symbols
internal/client/handler_test.go53 symbols

Dependencies from manifests, versioned

cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
github.com/Azure/azure-sdk-for-go/sdk/azcorev1.22.0 · 1×
github.com/Azure/azure-sdk-for-go/sdk/azidentityv1.14.0 · 1×
github.com/Azure/azure-sdk-for-go/sdk/internalv1.12.0 · 1×
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebusv1.10.0 · 1×
github.com/Azure/go-amqpv1.7.0 · 1×
github.com/AzureAD/microsoft-authentication-library-for-gov1.7.2 · 1×

Datastores touched

dbnameDatabase · 1 repos

For agents

$ claude mcp add centrifugo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact