RedisBroadcaster
Redis-based pub/sub broadcaster for multi-pod real-time synchronization.
Import
import { RedisBroadcaster } from '@gluonic/broadcaster-redis'Signature
function RedisBroadcaster(config: RedisBroadcasterConfig): BroadcasterInterfaceParameters
config: RedisBroadcasterConfig
| Property | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Redis connection URL |
channel | string | No | Pub/sub channel name (default: gluonic:sync) |
maxRetries | number | No | Max reconnection attempts (default: 10) |
retryDelay | number | No | Delay 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:
- Service isolation - Run Gluonic as separate service from main API
- Cross-service updates - Main API triggers sync updates via Redis
- Horizontal scaling - Multiple Gluonic pods communicate
See Also
- Real-Time Sync Guide - Full setup
- Deployment - Multi-pod deployment
- BroadcasterInterface - Interface details
Last updated on