export interface GatewayUserFlushEvent { userId: string; flushedAt: string; reason?: string; iconRevision?: string; } export interface GatewayFlushPublisher { publishUserFlush(userId: string, reason?: string, metadata?: { iconRevision?: string }): Promise; } export class RedisGatewayFlushPublisher implements GatewayFlushPublisher { private readonly channel: string; private readonly client: { publish: (channel: string, message: string) => Promise }; constructor(client: { publish: (channel: string, message: string) => Promise }, channel: string) { this.client = client; this.channel = channel; } async publishUserFlush(userId: string, reason?: string, metadata?: { iconRevision?: string }): Promise { const payload: GatewayUserFlushEvent = { userId, flushedAt: new Date().toISOString(), reason, ...(metadata?.iconRevision ? { iconRevision: metadata.iconRevision } : {}), }; await this.client.publish(this.channel, JSON.stringify(payload)); } }