Skip to Content
ReferenceServer APIRedisBroadcaster

RedisBroadcaster

Redis-based pub/sub broadcaster for multi-pod real-time synchronization.

Import

import { RedisBroadcaster } from '@gluonic/broadcaster-redis'

Signature

function RedisBroadcaster(config: RedisBroadcasterConfig): BroadcasterInterface

Parameters

config: RedisBroadcasterConfig

PropertyTypeRequiredDescription
urlstringYesRedis connection URL
channelstringNoPub/sub channel name (default: gluonic:sync)
maxRetriesnumberNoMax reconnection attempts (default: 10)
retryDelaynumberNoDelay between retries in ms (default: 1000)

Returns

BroadcasterInterface

interface BroadcasterInterface { publish(orgId: string, frames: SyncFrame[]): Promise<void> subscribe(handler: (orgId: string, frames: SyncFrame[]) => void): Promise<void> close(): Promise<void> }

Examples

Basic Usage

import { RedisBroadcaster } from '@gluonic/broadcaster-redis' const server = SyncServer({ database, auth: JWTAuth({ secret: process.env.JWT_SECRET }), broadcaster: RedisBroadcaster({ url: 'redis://localhost:6379' }) })

With Custom Channel

const broadcaster = RedisBroadcaster({ url: process.env.REDIS_URL, channel: 'my-app:sync' })

Production (AWS ElastiCache)

const broadcaster = RedisBroadcaster({ url: `rediss://${process.env.REDIS_ENDPOINT}:6379`, maxRetries: 5, retryDelay: 2000 })

Use Cases

When you need a broadcaster:

  1. Service isolation - Run Gluonic as separate service from main API
  2. Cross-service updates - Main API triggers sync updates via Redis
  3. Horizontal scaling - Multiple Gluonic pods communicate

See Also

Last updated on