跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Workflow.sleepUntil()

The .sleepUntil() method pauses execution until a specified date.

Usage example
Usage example的直接链接

workflow.sleepUntil(new Date(Date.now() + 5000))

Parameters
Parameters的直接链接

dateOrCallback:

Date | ExecuteFunction<TState, TPrevSchema, Date, any, any, TEngineType>
Either a Date object or a step-style execute function that returns a Date. The callback receives the execution context typed to the workflow state and the previous step output, and can compute the target time dynamically based on input data.

options?:

StepFlowEntryOptions
Optional identity and display metadata for this graph entry. Preserved through serialization and storage; has no effect on execution.
string
string
Record<string, unknown>

Returns
Returns的直接链接

workflow:

Workflow
The workflow instance for method chaining

Extended usage example
Extended usage example的直接链接

import { createWorkflow, createStep } from "@mastra/core/workflows";

const step1 = createStep({...});
const step2 = createStep({...});

export const testWorkflow = createWorkflow({...})
.then(step1)
.sleepUntil(async ({ inputData }) => {
const { delayInMs } = inputData;
return new Date(Date.now() + delayInMs);
})
.then(step2)
.commit();
On this page