andresusandi-pubsub
Version:
PubSub library that provides a number of different underlying technologies
17 lines (13 loc) • 599 B
JavaScript
const GooglePubSubBase = require('./GooglePubSubBase');
const { name: packageName } = require('./package.json');
class GooglePublisher extends GooglePubSubBase {
constructor(projectId, keyFilename, topicName, subscriptionName) {
super(projectId, keyFilename, topicName, subscriptionName);
}
async publishMessage(data) {
const dataBuffer = Buffer.from(data);
const messageId = await this.topic.publish(dataBuffer);
console.log(`${packageName}/${this.constructor.name} Published message with id: ${messageId}`);
}
}
module.exports = GooglePublisher;