Skip to content

Commit

Permalink
Merge pull request #202 from upstash/feature/scheduleToQueue
Browse files Browse the repository at this point in the history
DX-1384 Schedule to queues
  • Loading branch information
CahidArda authored Oct 28, 2024
2 parents 3494906 + 4bd48e6 commit a51c1ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client/schedules.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { afterEach, describe, expect, test } from "bun:test";
import { Client } from "./client";
Expand Down Expand Up @@ -32,6 +31,7 @@ describe("Schedules", () => {
failureCallback: "https://example.com/failure",
delay: 10,
retries: 5,
queueName: "scheduleQueue",
cron: "*/10 * * * * ",
});

Expand All @@ -51,6 +51,7 @@ describe("Schedules", () => {
delay: 10,
callback: "https://example.com",
failureCallback: "https://example.com/failure",
queueName: "scheduleQueue",
}) as Schedule
);

Expand Down
12 changes: 11 additions & 1 deletion src/client/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Schedule = {
failureCallback?: string;
callerIp?: string;
isPaused: boolean;
queueName?: string;
};

export type CreateScheduleRequest = {
Expand Down Expand Up @@ -108,11 +109,16 @@ export type CreateScheduleRequest = {
/**
* Schedule id to use.
*
* Can be used to updatine the settings of an existing schedule.
* Can be used to update the settings of an existing schedule.
*
* @default undefined
*/
scheduleId?: string;

/**
* Queue name to schedule the message over.
*/
queueName?: string;
};

export class Schedules {
Expand Down Expand Up @@ -177,6 +183,10 @@ export class Schedules {
headers.set("Upstash-Schedule-Id", request.scheduleId);
}

if (request.queueName !== undefined) {
headers.set("Upstash-Queue-Name", request.queueName);
}

return await this.http.request({
method: "POST",
headers,
Expand Down

0 comments on commit a51c1ac

Please sign in to comment.