Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function publishWithRetrySettings(projectId, topicName, data) {
// [START pubsub_publisher_retry_settings]
// Imports the Google Cloud client library
const {v1} = require('@google-cloud/pubsub');
// Creates a publisher client
const client = new v1.PublisherClient({
// optional auth parameters
});
/**
* TODO(developer): Uncomment the following lines to run the sample.
*/
// const projectId = 'my-project-id'
// const topicName = 'my-topic';
// const data = JSON.stringify({ foo: 'bar' });
const formattedTopic = client.topicPath(projectId, topicName);
// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)
const dataBuffer = Buffer.from(data);
const messagesElement = {
data: dataBuffer,
};