39 lines
526 B
TypeScript
39 lines
526 B
TypeScript
import * as amqp from "amqplib";
|
|
import { getLogger } from "./logger";
|
|
|
|
const logger = getLogger("CommandService");
|
|
|
|
export class CommandService {
|
|
|
|
|
|
constructor(
|
|
private channel: amqp.Channel
|
|
){}
|
|
|
|
|
|
|
|
async send(
|
|
queue:string,
|
|
command:any
|
|
){
|
|
|
|
|
|
await this.channel.sendToQueue(
|
|
|
|
queue,
|
|
|
|
Buffer.from(
|
|
JSON.stringify(command)
|
|
)
|
|
|
|
);
|
|
|
|
|
|
logger.debug(
|
|
"Command sent",
|
|
command
|
|
);
|
|
|
|
}
|
|
|
|
} |