wrappers/tests/testBroker.js
2024-10-09 00:03:42 +03:00

25 lines
658 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);
});