MCPcopy Index your code
hub / github.com/simstudioai/sim / LocalPubSubChannel

Class LocalPubSubChannel

apps/sim/lib/events/pubsub.ts:115–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115class LocalPubSubChannel<T> implements PubSubChannel<T> {
116 private emitter = new EventEmitter()
117
118 constructor(private config: PubSubChannelConfig) {
119 this.emitter.setMaxListeners(100)
120 logger.info(`${config.label}: Using process-local EventEmitter (Redis not configured)`)
121 }
122
123 publish(event: T): void {
124 this.emitter.emit(this.config.channel, event)
125 }
126
127 subscribe(handler: (event: T) => void): () => void {
128 this.emitter.on(this.config.channel, handler)
129 return () => {
130 this.emitter.off(this.config.channel, handler)
131 }
132 }
133
134 dispose(): void {
135 this.emitter.removeAllListeners()
136 logger.info(`${this.config.label} local pub/sub disposed`)
137 }
138}
139
140export function createPubSubChannel<T>(config: PubSubChannelConfig): PubSubChannel<T> {
141 const redisUrl = env.REDIS_URL

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected