Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

166 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressBus

A lightweight, high-performance pub/sub messaging system for real-time communication between clients and servers. ExpressBus is engineered for low latency and high throughput using a partitioned concurrency model.


Overview

ExpressBus consists of two primary components:

  • ExpressBus.Client: A client library for connecting to the broker, enabling subscription to topics and broadcasting of messages.
  • ExpressBus.Server: A high-performance broker that coordinates topic subscriptions and distributes broadcast messages to subscribers.

Quick Start

Client Usage

using System.Net;
using System.Text;
using ExpressBus.Client;

// 1. Connect to the server
var endpoint = new IPEndPoint(IPAddress.Loopback, 8080);
var client = new ExpressBusClient(endpoint);
await client.ConnectAsync();

// 2. Subscribe to a topic
var topic = Encoding.UTF8.GetBytes("news");
await client.SubscribeAsync(topic, async message => 
{
    Console.WriteLine($"Received: {Encoding.UTF8.GetString(message.Span)}");
});

// 3. Broadcast a message
await client.BroadcastAsync(topic, Encoding.UTF8.GetBytes("Hello, ExpressBus!"));

Server Usage

using System.Net;
using ExpressBus.Server;

var address = new IPEndPoint(IPAddress.Any, 8080);
var server = new ExpressBusServer(address);

await server.ListenAsync();

Key Architecture

High-Performance Design

ExpressBus minimizes contention using Partitioned Locking. Rather than a single global lock for all subscriptions, it divides the subscription space into partitions, allowing concurrent operations across different topics.

Pluggable Security

TLS encryption is supported via the IStreamTransformer interface. This allows you to inject custom security layers (like SslStream) without modifying the core network logic.

Memory Efficiency

The system uses ReadOnlyMemory<byte> throughout the pipeline to reduce allocations and avoid unnecessary copying of message payloads.


Project Structure

  • ExpressBus.Client — Client API and message dispatching.
  • ExpressBus.Server — Pub/Sub broker implementation.
  • ExpressBus.Protocol — Binary framing and serialization.
  • ExpressBus.Network — TCP connection management and stream abstraction.
  • ExpressBus.Concurrency — Specialized primitives for high-concurrency synchronization.
  • ExpressBus.Equality — Optimized memory comparers for topic matching.

Limitations

  • Single-Node Broker: Designed for high throughput on a single machine. Horizontal scaling requires an external orchestrator.
  • Ephemeral Messaging: Messages are broadcast in real-time; there is no built-in persistence or "message replay" for offline subscribers.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages