Skip to content

Commit

Permalink
Removed delivery delay from create consumer and queue
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiguel committed Feb 28, 2024
1 parent 7a71f7e commit 22cc5a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 57 deletions.
57 changes: 15 additions & 42 deletions packages/wrangler/src/__tests__/queues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ describe("wrangler", () => {
producers_total_count: 0,
consumers: [],
consumers_total_count: 0,
settings: {
delivery_delay: 0
}
},
{
queue_id: "def19fa3787741579c9088eb850474af",
Expand All @@ -112,6 +115,9 @@ describe("wrangler", () => {
producers_total_count: 0,
consumers: [],
consumers_total_count: 0,
settings: {
delivery_delay: 0
}
},
];
const expectedPage = 1;
Expand Down Expand Up @@ -141,6 +147,9 @@ describe("wrangler", () => {
producers_total_count: 0,
consumers: [],
consumers_total_count: 0,
settings: {
delivery_delay: 0
}
},
];
const expectedPage = 2;
Expand Down Expand Up @@ -216,8 +225,7 @@ describe("wrangler", () => {
-v, --version Show version number [boolean]
Options:
--no-delivery-delay Sets published messages to have no delay [boolean]
--delivery-delay How long a published messages should be delayed for, in seconds. Must be a positive integer [number]"
--delivery-delay How long a published messages should be delayed for, in seconds. Must be a positive integer [number]"
`);
});

Expand Down Expand Up @@ -280,22 +288,12 @@ describe("wrangler", () => {
expect(requests.count).toEqual(1);
});

it("should send send queue settings with 0 delivery delay when noDeliveryDelay is set", async () => {
const requests = mockCreateRequest("testQueue", { delivery_delay: 0 });
await runWrangler("queues create testQueue --no-delivery-delay");
expect(std.out).toMatchInlineSnapshot(`
"Creating queue testQueue.
Created queue testQueue."
`);
expect(requests.count).toEqual(1);
});

it("should show an error with delivery delay and no delivery delay are used", async () => {
it("should show an error when two delivery delays are set", async () => {
const requests = mockCreateRequest("testQueue", { delivery_delay: 0 });

await expect(
runWrangler(
"queues create testQueue --no-delivery-delay --delivery-delay=10"
"queues create testQueue --delivery-delay=5 --delivery-delay=10"
)
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Error: can't use more than a delay setting."`
Expand Down Expand Up @@ -436,8 +434,7 @@ describe("wrangler", () => {
--message-retries Maximum number of retries for each message [number]
--dead-letter-queue Queue to send messages that failed to be consumed [string]
--max-concurrency The maximum number of concurrent consumer Worker invocations. Must be a positive integer [number]
--retry-delay How long a retried messages should be delayed for, in seconds. Must be a positive integer [number]
--no-retry-delay Sets retried messages have no delay. [boolean]"
--retry-delay How long a retried messages should be delayed for, in seconds. Must be a positive integer [number]"
`);
});

Expand Down Expand Up @@ -486,31 +483,7 @@ describe("wrangler", () => {
`);
});

it("should add a consumer with no delay", async () => {
const expectedBody: PostConsumerBody = {
script_name: "testScript",
environment_name: "myEnv",
settings: {
batch_size: 20,
max_retries: 3,
max_wait_time_ms: 10 * 1000,
max_concurrency: 3,
retry_delay: 0,
},
dead_letter_queue: "myDLQ",
};
mockPostRequest("testQueue", expectedBody);

await runWrangler(
"queues consumer add testQueue testScript --env myEnv --batch-size 20 --batch-timeout 10 --message-retries 3 --max-concurrency 3 --dead-letter-queue myDLQ --no-retry-delay"
);
expect(std.out).toMatchInlineSnapshot(`
"Adding consumer to queue testQueue.
Added consumer to queue testQueue."
`);
});

it("should show an error with retry delay and no retry delay are used", async () => {
it("should show an error when two retry delays are set", async () => {
const expectedBody: PostConsumerBody = {
script_name: "testScript",
environment_name: "myEnv",
Expand All @@ -527,7 +500,7 @@ describe("wrangler", () => {

await expect(
runWrangler(
"queues consumer add testQueue testScript --env myEnv --batch-size 20 --batch-timeout 10 --message-retries 3 --max-concurrency 3 --dead-letter-queue myDLQ --no-retry-delay --retry-delay=10"
"queues consumer add testQueue testScript --env myEnv --batch-size 20 --batch-timeout 10 --message-retries 3 --max-concurrency 3 --dead-letter-queue myDLQ --retry-delay=5 --retry-delay=10"
)
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Error: can't use more than a delay setting."`
Expand Down
10 changes: 2 additions & 8 deletions packages/wrangler/src/queues/cli/commands/consumer/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ export function options(yargs: CommonYargsArgv) {
type: "number",
describe: "How long a retried messages should be delayed for, in seconds. Must be a positive integer",
number: true,
},
"no-retry-delay": {
type: "boolean",
describe: "Sets retried messages have no delay.",
boolean: true
},
})
.conflicts('retry-delay', 'no-retry-delay')
}
});
}

function createBody(args: StrictYargsOptionsToInterface<typeof options>): PostConsumerBody {
Expand Down
8 changes: 1 addition & 7 deletions packages/wrangler/src/queues/cli/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ export function options(yargs: CommonYargsArgv) {
description: "The name of the queue",
})
.options({
"no-delivery-delay": {
type: "boolean",
describe: "Sets published messages to have no delay",
boolean: true,
},
"delivery-delay": {
type: "number",
describe: "How long a published messages should be delayed for, in seconds. Must be a positive integer",
}
})
.conflicts('delivery-delay', 'no-delivery-delay')
});
}

function createBody(args: StrictYargsOptionsToInterface<typeof options>): CreateQueueBody {
Expand Down

0 comments on commit 22cc5a5

Please sign in to comment.