wrappers/tests/testBroker.js

25 lines
658 B
JavaScript
Raw Permalink Normal View History

import { readFileSync } from 'fs';
2023-07-03 15:33:39 +02:00
import { MessageBroker } from '../build/esm/index.js';
const credentials = JSON.parse(readFileSync('../brokerCreds.json', { encoding: 'utf-8' }));
2023-07-03 15:33:39 +02:00
const broker = new MessageBroker({
createLogger: () =>
2023-07-03 15:33:39 +02:00
{
return {
debug: console.log,
info: console.log,
2023-07-03 15:33:39 +02:00
status: console.log,
warn: console.log,
error: console.error
2023-07-03 15:33:39 +02:00
};
}
}, credentials);
2023-07-03 15:33:39 +02:00
await broker.init();
broker.subscribe('db_cluster_status', (message) =>
2023-07-03 15:33:39 +02:00
{
if (message instanceof Buffer)
console.log(message.toString());
else
console.log(message);
2023-07-03 15:33:39 +02:00
});