Skip to content

Commit

Permalink
chore: fix typo for maxRetries in queues configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sdnts committed Oct 14, 2024
1 parent b10461e commit 3c03c92
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/miniflare/src/workers/queues/broker.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class QueueBrokerObject extends MiniflareDurableObject<QueueBrokerObjectE
assert(consumer !== undefined);

const batchSize = consumer.maxBatchSize ?? DEFAULT_BATCH_SIZE;
const maxAttempts = (consumer.maxRetires ?? DEFAULT_RETRIES) + 1;
const maxAttempts = (consumer.maxRetries ?? DEFAULT_RETRIES) + 1;
const maxAttemptsS = maxAttempts === 1 ? "" : "s";

// Extract and dispatch a batch
Expand Down
27 changes: 18 additions & 9 deletions packages/miniflare/src/workers/queues/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ export type QueueProducer = z.infer<typeof QueueProducerSchema>;
export const QueueProducersSchema =
/* @__PURE__ */ z.record(QueueProducerSchema);

export const QueueConsumerOptionsSchema = /* @__PURE__ */ z.object({
// https://developers.cloudflare.com/queues/platform/configuration/#consumer
// https://developers.cloudflare.com/queues/platform/limits/
maxBatchSize: z.number().min(0).max(100).optional(),
maxBatchTimeout: z.number().min(0).max(30).optional(), // seconds
maxRetires: z.number().min(0).max(100).optional(),
deadLetterQueue: z.ostring(),
retryDelay: QueueMessageDelaySchema,
});
export const QueueConsumerOptionsSchema = /* @__PURE__ */ z
.object({
// https://developers.cloudflare.com/queues/platform/configuration/#consumer
// https://developers.cloudflare.com/queues/platform/limits/
maxBatchSize: z.number().min(0).max(100).optional(),
maxBatchTimeout: z.number().min(0).max(30).optional(), // seconds
maxRetires: z.number().min(0).max(100).optional(), // deprecated
maxRetries: z.number().min(0).max(100).optional(),
deadLetterQueue: z.ostring(),
retryDelay: QueueMessageDelaySchema,
})
.transform((queue) => {
if (queue.maxRetires !== undefined) {
queue.maxRetries = queue.maxRetires;
}

return queue as Omit<typeof queue, "maxRetires">;
});
export const QueueConsumerSchema = /* @__PURE__ */ z.intersection(
QueueConsumerOptionsSchema,
z.object({ workerName: z.string() })
Expand Down
8 changes: 4 additions & 4 deletions packages/miniflare/test/plugins/queues/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ test("sends all structured cloneable types", async (t) => {

queueProducers: ["QUEUE"],
queueConsumers: {
QUEUE: { maxBatchSize: 100, maxBatchTimeout: 0, maxRetires: 0 },
QUEUE: { maxBatchSize: 100, maxBatchTimeout: 0, maxRetries: 0 },
},
serviceBindings: {
async REPORTER(request) {
Expand Down Expand Up @@ -433,7 +433,7 @@ test("retries messages", async (t) => {
log,
queueProducers: { QUEUE: { queueName: "queue" } },
queueConsumers: {
queue: { maxBatchSize: 5, maxBatchTimeout: 1, maxRetires: 2 },
queue: { maxBatchSize: 5, maxBatchTimeout: 1, maxRetries: 2 },
},
serviceBindings: {
async RETRY_FILTER(request) {
Expand Down Expand Up @@ -685,13 +685,13 @@ test("moves to dead letter queue", async (t) => {
bad: {
maxBatchSize: 5,
maxBatchTimeout: 1,
maxRetires: 0,
maxRetries: 0,
deadLetterQueue: "dlq",
},
dlq: {
maxBatchSize: 5,
maxBatchTimeout: 1,
maxRetires: 0,
maxRetries: 0,
deadLetterQueue: "bad", // (cyclic)
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/dev/miniflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function queueConsumerEntry(consumer: QueueConsumer) {
const options = {
maxBatchSize: consumer.max_batch_size,
maxBatchTimeout: consumer.max_batch_timeout,
maxRetires: consumer.max_retries,
maxRetries: consumer.max_retries,
deadLetterQueue: consumer.dead_letter_queue,
retryDelay: consumer.retry_delay,
};
Expand Down

0 comments on commit 3c03c92

Please sign in to comment.