Thijs Koerselman
Thijs Koerselman

Reputation: 23290

How to implement a pull-queue using Cloud Tasks in Node.js

I am trying to implement a pull-queue using Cloud Tasks + App Engine standard environment in Node.js. So basically I am trying to lease tasks from a queue. The problem is that I can only find examples in other languages, and I can find no mention of creating or leasing tasks for pull queues in the GCP Node.js documentation.

Please tell me this is possible and I do not need to start using a different language in my project only to implement a pull-queue mechanism.

Here is a link to the equivalent Python documentation

--- edit ---

I managed to find a reference in the types that allowed me to do this:

import { v2beta2 } from "@google-cloud/tasks";
const client = new v2beta2.CloudTasksClient();
const [{ tasks }] = await client.leaseTasks({
  parent: client.queuePath(project, location, "my-pull-queue"),
  maxTasks: 100,
});

...but it is giving me some odd quota error:

Error: Failed to lease tasks from the my-pull-queue queue: 8 RESOURCE_EXHAUSTED: Quota exceeded for quota metric 'Alpha API requests' and limit 'Alpha API requests per minute (should be 0 unless whitelisted)' of service 'cloudtasks.googleapis.com' for consumer 'project_number:xxx'.

I can hardly find sources referencing this type of quota error, but it seems to stem from APIs that are not made public yet and can only be used when access is granted explicitly (which would explain the whitelisting).

Another thing I find very odd is that there seem to be two beta clients v2beta2 and v2beta3, but only beta2 types define methods for leasing a task. Both beta APIs are defining types for creating a pull-queue task.

Upvotes: -1

Views: 1241

Answers (1)

Thijs Koerselman
Thijs Koerselman

Reputation: 23290

I just found this statement that pull-queues are not supported in Node.js.

https://github.com/googleapis/nodejs-tasks/issues/123#issuecomment-445090253

Upvotes: 1

Related Questions