Closed
Description
Is your feature request related to a problem? Please describe.
No.
Describe the solution you'd like
The Cloud Tasks API allows you to specify a task's name explicitly but the SDK does not currently expose this. This is useful for task de-duplication, for example. It would be great to expose this via TaskOptions through a name
property like so:
const queue = getFunctions().taskQueue("taskFunction");
queue.enqueue(
{ ... },
{ name: "task-name" }
);
Describe alternatives you've considered
The workaround is to use the @google-cloud/tasks
SDK directly like so:
import { CloudTasksClient } from "@google-cloud/tasks";
const client = new CloudTasksClient();
const name = "task-name";
const projectId = "project-name";
const location = "us-central1";
const functionName = "taskFunction";
const serviceAccountEmail = `${projectId}@appspot.gserviceaccount.com`;
const parent = client.queuePath(
projectId,
location,
functionName
);
const url = `https://${location}-${projectId}.cloudfunctions.net/${functionName}`;
client
.createTask({
parent: parent,
task: {
name: `${parent}/tasks/${name}`,
httpRequest: {
headers: {
"Content-Type": "application/json",
},
body: Buffer.from(
JSON.stringify({ data: {} })
).toString("base64"),
httpMethod: "POST",
url: url,
oidcToken: { serviceAccountEmail },
},
},
});
Additional context
While the solution above works, it is clearly far more verbose and cumbersome than if the firebase admin were to expose this functionality directly.