diff --git a/README.md b/README.md index 12a3e1b..c83be33 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,6 @@ export default fn; export const runtimeConfig: GcpConfig = { cloud: "gcp", type: "queue", - // By defining the queueName it will create the queue for you. - queueName: "hello-world", }; ``` diff --git a/build/esbuild/bundle.ts b/build/esbuild/bundle.ts index cd9873a..1cd6b23 100644 --- a/build/esbuild/bundle.ts +++ b/build/esbuild/bundle.ts @@ -50,11 +50,10 @@ function generateFunctionName(file: string) { .replace(/(src|index|functions|function|\.ts)/g, "") .replace(/^\//, "") .replace(/\/$/, "") - .replace(/[\/]{2,}/g, "/") - .replace(/\//g, "-") - .replace(/[-_]{2,}/g, "-") - .replace(/^[-_]+/, "") - .replace(/[-_]+$/, ""); + .replace(/[\/_]/g, "-") + .replace(/[-]{2,}/g, "-") + .replace(/^[-]+/, "") + .replace(/[-]+$/, ""); } function detectRuntimeConfig(node: ts.Node) { diff --git a/docs/queue.md b/docs/queue.md index dbd6bfd..894ebc1 100644 --- a/docs/queue.md +++ b/docs/queue.md @@ -1,6 +1,6 @@ # Queue Functions -If you want your function to be triggered by a Cloud Tasks queue, you can use the `queue` type in the runtimeConfig, which requires the `queueName` property which is a string defining the name of the queue you'd like to create. +If you want your function to be triggered by a Cloud Tasks queue, you can use the `queue` type in the runtimeConfig. ## Code sample @@ -18,7 +18,5 @@ export default fn; export const runtimeConfig: GcpConfig = { cloud: "gcp", type: "queue", - // By defining the queueName it will create the queue for you. - queueName: "hello-world", }; ``` diff --git a/stacks/gcp/GcpStack.ts b/stacks/gcp/GcpStack.ts index 48c3183..10144bf 100644 --- a/stacks/gcp/GcpStack.ts +++ b/stacks/gcp/GcpStack.ts @@ -126,9 +126,9 @@ export default class GcpStack extends TerraformStack { } // Create Cloud Tasks queue if it doesn't exist already - if (func.type === "queue" && !this.existingQueues.includes(func.queueName)) { - new CloudTasksQueue(this, func.queueName, { - name: func.queueName, + if (func.type === "queue" && !this.existingQueues.includes(func.name)) { + new CloudTasksQueue(this, func.name + "-queue", { + name: func.name, location: this.options.gcpOptions.region, rateLimits: { maxConcurrentDispatches: func.queueConfig?.maxConcurrentDispatches, @@ -142,7 +142,7 @@ export default class GcpStack extends TerraformStack { maxRetryDuration: func.queueConfig?.maxRetryDuration, }, }); - this.existingQueues.push(func.queueName); + this.existingQueues.push(func.name); } // Configure static IP constraint diff --git a/types/runtime.ts b/types/runtime.ts index afc5fe3..a01d36e 100644 --- a/types/runtime.ts +++ b/types/runtime.ts @@ -36,7 +36,6 @@ export type ScheduleConfig = { export type QueueConfig = { type: "queue"; - queueName: string; queueConfig?: { maxDispatchesPerSecond?: number; maxConcurrentDispatches?: number;