import { Channel, Connection } from "amqplib"; export class ConnectionHandler { constructor( private reconnect: () => Promise, private recreateChannel: () => Promise ) {} async handleConnectionError(error: Error): Promise { console.error("Connection error:", error); await this.reconnect(); } async handleConnectionClosed(): Promise { console.warn("Connection closed, attempting to reconnect..."); await this.reconnect(); } async handleChannelError(error: Error): Promise { console.error("Channel error:", error); await this.recreateChannel(); } async handleChannelClosed(): Promise { console.warn("Channel closed, attempting to recreate..."); await this.recreateChannel(); } }