Use Google Cloud Tasks as queue to push jobs to your worker instance
Integration type
Category
Last published
Downloads in past month
Plugin for using Vendure worker with Google Cloud Tasks. This plugin will show ending, successful and failed jobs in the admin UI under sytem/jobs
, but not running jobs. Only jobs of the past 7 days are kept in the DB.
DefaultJobQueuePlugin
from your vendure-config. Add this plugin to your vendure-config.ts
:import { CloudTasksPlugin } from '@pinelab/vendure-plugin-google-cloud-tasks';
plugins: [
CloudTasksPlugin.init({
// Must reachable by Google Cloud Task. Messages are pushed to this endpoint
taskHandlerHost: 'https://your-public-host/',
projectId: 'your-google-project-id',
// Region where the taskqueue should be created
location: 'europe-west1',
// Used to prevent unauithorized requests to your public endpoint
authSecret: 'some-secret-to-authenticate-incoming-messages',
/**
* Used to distinguish taskQueues within the same
* Google Project (if you have OTAP environments in the same project for example)
* This suffix will be appended to the queue name: "send-email-plugin-test"
*/
queueSuffix: 'plugin-test',
// Default amount of retries when no job.retries is given
defaultJobRetries: 15,
// The amount of retries when a job fails to be pushed to the queue
createTaskRetries: 3,
}),
];
Products > (cog icon) > reindex
to test the Cloud Tasks Plugin.You can call the endpoint /cloud-tasks/clear-jobs/X
with the secret as Auth header to clear jobs older than X days. For example:
curl -H "Authorization: Bearer some-secret-to-authenticate-cloud-tasks" "http://localhost:3050/cloud-tasks/clear-jobs/1"
Will clear all jobs older than 1 day.
When pushing multiple tasks concurrently to a queue in serverless environments, you might see DEADLINE_EXCEEDED
errors. If that happens, you can instantiate the plugin with fallback: true
to make the Google Cloud Tasks client fallback to HTTP instead of GRPC. For more details see https://github.com/googleapis/nodejs-tasks/issues/397#issuecomment-618580649
CloudTasksPlugin.init({
...
clientOptions: {
fallback: true
}
});