25 lines
654 B
JavaScript
25 lines
654 B
JavaScript
import { readFileSync } from 'fs';
|
|
import { MessageBroker } from '../build/esm/index.js';
|
|
const credentials = JSON.parse(readFileSync('../brokerCreds.json', { encoding: 'utf-8' }));
|
|
|
|
const broker = new MessageBroker({
|
|
createLogger: () =>
|
|
{
|
|
return {
|
|
debug: console.log,
|
|
info: console.log,
|
|
status: console.log,
|
|
warn: console.log,
|
|
error: console.error
|
|
};
|
|
}
|
|
}, credentials);
|
|
|
|
await broker.init();
|
|
broker.subscribe('db_cluster_status', (message) =>
|
|
{
|
|
if (message instanceof Buffer)
|
|
console.log(message.toString());
|
|
else
|
|
console.log(message);
|
|
}); |