MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

cloud-tasks/snippets/createQueue.js:20–52  ·  view source on GitHub ↗

* Create a new Task Queue

(
  project = 'my-project-id', // Your GCP Project id
  queue = 'my-appengine-queue', // Name of the Queue to create
  location = 'us-central1' // The GCP region in which to create the queue
)

Source from the content-addressed store, hash-verified

18 * Create a new Task Queue
19 */
20function main(
21 project = 'my-project-id', // Your GCP Project id
22 queue = 'my-appengine-queue', // Name of the Queue to create
23 location = 'us-central1' // The GCP region in which to create the queue
24) {
25 // [START cloud_tasks_create_queue]
26 // Imports the Google Cloud Tasks library.
27 const cloudTasks = require('@google-cloud/tasks');
28
29 // Instantiates a client.
30 const client = new cloudTasks.CloudTasksClient();
31
32 async function createQueue() {
33 // Send create queue request.
34 const [response] = await client.createQueue({
35 // The fully qualified path to the location where the queue is created
36 parent: client.locationPath(project, location),
37 queue: {
38 // The fully qualified path to the queue
39 name: client.queuePath(project, location, queue),
40 appEngineHttpQueue: {
41 appEngineRoutingOverride: {
42 // The App Engine service that will receive the tasks.
43 service: 'default',
44 },
45 },
46 },
47 });
48 console.log(`Created queue ${response.name}`);
49 }
50 createQueue();
51 // [END cloud_tasks_create_queue]
52}
53
54process.on('unhandledRejection', err => {
55 console.error(err.message);

Callers 1

createQueue.jsFile · 0.70

Calls 1

createQueueFunction · 0.85

Tested by

no test coverage detected