Bring your own broker adapter
Documentation for Redweb 0.13.2. Install that exact version when following these examples.
Redweb supplies a bounded composition seam rather than choosing infrastructure. Events are finite, deduplicated briefly, and explicitly best-effort.
This pattern demonstrates one API area. Application-specific names, credentials, assets, and policies may need to be supplied. Complete starter recipes include all required application files.
const { SocketRoute } = require('redweb')
class DistributedMatchRoute extends SocketRoute {
constructor() {
super({
path: '/match',
handlers: [JoinMatchHandler, MoveMatchHandler, ResumeMatchHandler],
rooms: true,
distribution: {
adapter: brokerAdapter,
channel: 'matches',
nodeId: process.env.INSTANCE_ID,
required: true,
maxEventBytes: 64 * 1024,
maxConcurrentPublishes: 32,
onEvent(event, route) {
route.rooms.broadcast(event.payload.roomId, {
type: event.type,
payload: event.payload,
})
},
},
})
}
}
// From a connected socket:
await socket.publishEvent('match:update', update)Notes and boundaries
- Required adapters affect readiness; best-effort adapters do not.
- Source-node events are ignored to prevent reflection loops.
- Authoritative state and partition reconciliation remain application work.