fix rabbitmq export
This commit is contained in:
parent
70f041f1ad
commit
ca432f99b9
@ -1,14 +1,18 @@
|
|||||||
import amqp, { Connection, Channel } from "amqplib";
|
import amqp, { Connection, Channel } from "amqplib";
|
||||||
import Config from "./Config";
|
import Config from "./Config";
|
||||||
|
|
||||||
var rabbitCon: Connection;
|
export const RabbitMQ: { connection: Connection | null; channel: Channel | null; init: () => Promise<void> } = {
|
||||||
var rabbitCh: Channel;
|
connection: null,
|
||||||
|
channel: null,
|
||||||
export async function init() {
|
init: async function () {
|
||||||
const host = Config.get().rabbitmq.host;
|
const host = Config.get().rabbitmq.host;
|
||||||
if (!host) return;
|
if (!host) return;
|
||||||
rabbitCon = await amqp.connect(host);
|
console.log(`[RabbitMQ] connect: ${host}`);
|
||||||
rabbitCh = await rabbitCon.createChannel();
|
this.connection = await amqp.connect(host, {
|
||||||
}
|
timeout: 1000 * 60,
|
||||||
|
});
|
||||||
export { rabbitCon, rabbitCh };
|
console.log(`[RabbitMQ] connected`);
|
||||||
|
this.channel = await this.connection.createChannel();
|
||||||
|
console.log(`[RabbitMQ] channel created`);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user