in src/scaler/scaler-core/utils.js [71:98]
async function publishProtoMsgDownstream(eventName, jsonData, topicId) {
if (!topicId) {
logger.debug(
`If you want ${eventName} messages published downstream then specify ` +
'downstreamPubSubTopic in your config.',
);
return Promise.resolve();
}
const topic = pubsub.topic(topicId);
const message = await createProtobufMessage(jsonData);
const data = Buffer.from(JSON.stringify(message.toJSON()));
const attributes = {event: eventName};
return topic
.publishMessage({data: data, attributes: attributes})
.then(() =>
logger.info(
`Published ${eventName} message downstream to topic: ${topicId}`,
),
)
.catch((err) => {
logger.error({
message: `An error occurred publishing ${eventName} message downstream to topic: ${topicId}: ${err}`,
err: err,
});
});
}