Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe("workflow client", () => {
workflowRunId: myWorkflowRunId2,
retries: 15,
retryDelay: "2000",
delay: 1,
notBefore: new Date("2100-01-01T00:00:00Z").getTime() / 1000,
useFailureFunction: true,
},
]);
Expand Down Expand Up @@ -326,7 +326,7 @@ describe("workflow client", () => {
"upstash-workflow-init": "true",
"upstash-workflow-runid": `wfr_${myWorkflowRunId2}`,
"upstash-workflow-url": "https://requestcatcher.com/api",
"upstash-delay": "1s",
"upstash-not-before": "4102444800",
"content-type": "application/json",
"upstash-feature-set": "LazyFetch,InitialBody,WF_DetectTrigger",
"upstash-telemetry-framework": "unknown",
Expand Down
1 change: 1 addition & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export class Client {
workflowContext: context,
telemetry: { sdk: SDK_TELEMETRY },
delay: option.delay,
notBefore: option.notBefore,
};
});
const result = await triggerFirstInvocation(invocations);
Expand Down
10 changes: 10 additions & 0 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ export type TriggerOptions = {
* Delay to apply before triggering the workflow.
*/
delay?: PublishRequest["delay"];
/**
* Optionally set the absolute delay of this message.
* This will override the delay option.
* The message will not delivered until the specified time.
*
* Unix timestamp in seconds.
*
* @default undefined
*/
notBefore?: PublishRequest["notBefore"];
/**
* Label to apply to the workflow run.
*
Expand Down
4 changes: 3 additions & 1 deletion src/workflow-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type TriggerFirstInvocationParams<TInitialPayload> = {
debug?: WorkflowLogger;
invokeCount?: number;
delay?: PublishRequest["delay"];
notBefore?: PublishRequest["notBefore"];
};

export const triggerFirstInvocation = async <TInitialPayload>(
Expand All @@ -44,7 +45,7 @@ export const triggerFirstInvocation = async <TInitialPayload>(
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;

const invocationBatch = firstInvocationParams.map(
({ workflowContext, useJSONContent, telemetry, invokeCount, delay }) => {
({ workflowContext, useJSONContent, telemetry, invokeCount, delay, notBefore }) => {
const { headers } = getHeaders({
initHeaderValue: "true",
workflowConfig: {
Expand Down Expand Up @@ -93,6 +94,7 @@ export const triggerFirstInvocation = async <TInitialPayload>(
body,
url: workflowContext.url,
delay: delay,
notBefore: notBefore,
} as PublishBatchRequest;
}
);
Expand Down
Loading