@bonniernews/b0rker
Advanced tools
Comparing version 9.2.2 to 9.3.0
@@ -10,14 +10,19 @@ import { CloudTasksClient } from "@google-cloud/tasks"; | ||
const { queues, selfUrl, localPort } = config.cloudTasks || {}; | ||
const cloudTasksClient = new CloudTasksClient( | ||
localPort | ||
? { | ||
port: localPort, | ||
servicePath: "localhost", | ||
sslCreds: gax.ChannelCredentials.createInsecure(), | ||
} | ||
: {}, | ||
gax | ||
); | ||
const { queues, selfUrl, localPort, useHttpFallback } = config.cloudTasks || {}; | ||
const cloudTasksClient = getCloudTasksClient(); | ||
function getCloudTasksClient() { | ||
if (useHttpFallback) return new CloudTasksClient({ fallback: true }); | ||
return new CloudTasksClient( | ||
localPort | ||
? { | ||
port: localPort, | ||
servicePath: "localhost", | ||
sslCreds: gax.ChannelCredentials.createInsecure(), | ||
} | ||
: {}, | ||
gax | ||
); | ||
} | ||
// Google recommends to rate limit the amount of published tasks per second | ||
@@ -61,15 +66,18 @@ const maxTasksPublishedPerSecond = 500; | ||
logger.info(`Sending task ${JSON.stringify(body)} with headers ${JSON.stringify(newHeaders)} to ${url}`); | ||
await cloudTasksClient.createTask({ | ||
parent: queueName, | ||
task: { | ||
name: buildTaskName(taskUrl, body, queueName, correlationId, headers?.resendNumber), | ||
httpRequest: { | ||
httpMethod: "POST", | ||
headers: newHeaders, | ||
url, | ||
body: Buffer.from(JSON.stringify(body, null, 2)), | ||
dispatchDeadline: 30 * 60, // 30 minutes | ||
await cloudTasksClient.createTask( | ||
{ | ||
parent: queueName, | ||
task: { | ||
name: buildTaskName(taskUrl, body, queueName, correlationId, headers?.resendNumber), | ||
httpRequest: { | ||
httpMethod: "POST", | ||
headers: newHeaders, | ||
url, | ||
body: Buffer.from(JSON.stringify(body, null, 2)), | ||
dispatchDeadline: 30 * 60, // 30 minutes | ||
}, | ||
}, | ||
}, | ||
}); | ||
{ retry: { backoffSettings: { maxRetries: 5, initialRetryDelayMillis: 1000, retryDelayMultiplier: 2 } } } | ||
); | ||
} | ||
@@ -76,0 +84,0 @@ |
{ | ||
"name": "@bonniernews/b0rker", | ||
"version": "9.2.2", | ||
"version": "9.3.0", | ||
"engines": { | ||
@@ -30,3 +30,3 @@ "node": ">=18" | ||
"@google-cloud/pubsub": "^4.0.7", | ||
"@google-cloud/tasks": "^5.1.1", | ||
"@google-cloud/tasks": "^5.3.0", | ||
"axios": "^1.6.2", | ||
@@ -33,0 +33,0 @@ "camelcase": "^8.0.0", |
290250
7597
Updated@google-cloud/tasks@^5.3.0