Skip to content

zacksfF/PubSubGo

Repository files navigation

PubSubGo

A high-performance, scalable message broker built with Go

Go Version License Build Status Docker

GitHub stars GitHub forks

Overview

PubSubGo is a modern, production-ready message broker that implements the publish-subscribe pattern with enterprise-grade features. Built from the ground up in Go, it provides blazing-fast message delivery, horizontal scalability, and comprehensive observability.

Goal: Simplify distributed system communication with a lightweight, feature-rich message broker that scales from development to production.

Key Features

Performance & Scalability

  • 100K+ messages/sec throughput
  • Sub-5ms latency (P99)
  • Horizontal scaling with partitioned topics
  • Connection pooling and batch operations

Reliability & Persistence

  • Redis clustering support for persistence
  • Message acknowledgments (ACK/NACK)
  • Dead letter queues for failed messages
  • Consumer groups with automatic rebalancing

Modern Observability

  • Prometheus metrics integration
  • Jaeger distributed tracing
  • Grafana dashboards included
  • Health checks and monitoring APIs

Multiple Interfaces

  • HTTP REST API for universal access
  • WebSocket real-time subscriptions
  • Go library for native integration
  • CLI tool for operations and testing

Architecture & Why It's Unique

Clean Architecture: Domain-driven design with clear separation of concerns

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Clients   │──▢│   PubSubGo   │──▢│ Storage/Redis   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚  Monitoring  β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

What makes it unique:

  • Clean Architecture - Testable, maintainable, and extensible
  • Multiple Storage - Memory, Redis, or custom adapters
  • Real-time & Batch - WebSocket streams + HTTP REST
  • Production Ready - Monitoring, tracing, and deployment tools included

Quick Start

Installation

# Clone and build
git clone https://github.com/zacksfF/PubSubGo.git
cd PubSubGo
make build

# Or using Docker
docker run -p 8081:8081 -p 9092:9092 pubsubgo/server

Start Server

./bin/pubsubgo-server
# Server starts on :8081, metrics on :9092

Usage

Go Library

package main

import (
    "net/http"
    "encoding/json"
)

func main() {
    // Create topic
    http.Post("http://localhost:8081/v1/topics", "application/json",
        strings.NewReader(`{"name":"events","partitions":3}`))
    
    // Publish message
    http.Post("http://localhost:8081/v1/publish/events", "application/json",
        strings.NewReader(`{"payload":"Hello World!"}`))
    
    // Subscribe via WebSocket
    ws, _ := websocket.Dial("ws://localhost:8081/ws", "", "http://localhost/")
    ws.Write([]byte(`{"action":"subscribe","topic":"events"}`))
}

CLI Tool

# Create topic
pubsubgo-cli topics create --name orders --partitions 3

# Publish message
pubsubgo-cli publish --topic orders --message "New order #123"

# Subscribe
pubsubgo-cli subscribe --topic orders --consumer worker-1

HTTP API

# Health check
curl http://localhost:8081/health

# Create topic
curl -X POST http://localhost:8081/v1/topics \
  -d '{"name":"events","partitions":3}'

# Publish message
curl -X POST http://localhost:8081/v1/publish/events \
  -d '{"payload":"Hello World!"}'

# WebSocket (using wscat)
wscat -c ws://localhost:8081/ws
> {"action":"subscribe","topic":"events"}

Use Cases

Enterprise Applications

// Order processing pipeline
orders β†’ validation β†’ payment β†’ fulfillment β†’ notifications

Microservices Communication

// Event-driven architecture
user-service β†’ pubsubgo β†’ [email-service, analytics-service, audit-service]

Real-time Analytics

// Live data streaming
sensors β†’ pubsubgo β†’ [dashboard, alerts, storage]

Gaming & Chat

// Real-time messaging
game-events β†’ pubsubgo β†’ [players, leaderboards, analytics]

Deployment

Docker Compose

version: '3.8'
services:
  pubsubgo:
    image: pubsubgo/server
    ports: ["8081:8081", "9092:9092"]
  redis:
    image: redis:7-alpine
    ports: ["6379:6379"]

Kubernetes

kubectl apply -k deployments/kubernetes/overlays/production/

Monitoring Stack

make monitoring-up
# Grafana: http://localhost:3000 (admin/admin123)
# Prometheus: http://localhost:9090
# Jaeger: http://localhost:16686

Getting Started

  1. Quick Start Guide - Get running in 5 minutes
  2. Examples - Go library, CLI, and HTTP examples
  3. Monitoring Setup - Grafana dashboards and metrics
  4. Deployment Guide - Docker, Kubernetes, and Istio
  5. Architecture Overview - System design and patterns

Contributing

We welcome contributions! See our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Star History

Star History Chart


Built with ❀️ by ZacksfF

Documentation β€’ Report Bug β€’ Request Feature

Releases

No releases published

Packages

No packages published