1
1
import { NotifyResponse , Waiter } from "../types" ;
2
- import { FlowControl , Client as QStashClient } from "@upstash/qstash" ;
2
+ import { FlowControl , PublishRequest , Client as QStashClient } from "@upstash/qstash" ;
3
3
import { makeGetWaitersRequest , makeNotifyRequest } from "./utils" ;
4
4
import { getWorkflowRunId } from "../utils" ;
5
5
import { triggerFirstInvocation } from "../workflow-requests" ;
@@ -190,6 +190,11 @@ export class Client {
190
190
* with `wfr_`.
191
191
* @param retries retry to use in the initial request. in the rest of
192
192
* the workflow, `retries` option of the `serve` will be used.
193
+ * @param flowControl Settings for controlling the number of active requests
194
+ * and number of requests per second with the same key.
195
+ * @param delay Delay for the workflow run. This is used to delay the
196
+ * execution of the workflow run. The delay is in seconds or can be passed
197
+ * as a string with a time unit (e.g. "1h", "30m", "15s").
193
198
* @returns workflow run id
194
199
*/
195
200
public async trigger ( {
@@ -199,13 +204,15 @@ export class Client {
199
204
workflowRunId,
200
205
retries,
201
206
flowControl,
207
+ delay,
202
208
} : {
203
209
url : string ;
204
210
body ?: unknown ;
205
211
headers ?: Record < string , string > ;
206
212
workflowRunId ?: string ;
207
213
retries ?: number ;
208
214
flowControl ?: FlowControl ;
215
+ delay ?: PublishRequest [ "delay" ] ;
209
216
} ) : Promise < { workflowRunId : string } > {
210
217
const finalWorkflowRunId = getWorkflowRunId ( workflowRunId ) ;
211
218
const context = new WorkflowContext ( {
@@ -223,6 +230,7 @@ export class Client {
223
230
const result = await triggerFirstInvocation ( {
224
231
workflowContext : context ,
225
232
telemetry : undefined , // can't know workflow telemetry here
233
+ delay,
226
234
} ) ;
227
235
if ( result . isOk ( ) ) {
228
236
return { workflowRunId : finalWorkflowRunId } ;
0 commit comments