createWorkflow
createWorkflow():
Workflow
定义于:core/src/core/workflow.ts:115
创建一个新的工作流实例。
这是用于创建工作流的主要工厂函数。每个工作流 维护其自身的事件处理器注册表,并能创建多个 独立的执行上下文。
一个新的工作流实例
// Create a simple workflowconst workflow = createWorkflow();
// Register handlersworkflow.handle([InputEvent], async (context, event) => \{ const processed = await processInput(event.data); return OutputEvent.with(processed);\});
// Use the workflowconst context = workflow.createContext();const input = InputEvent.with(\{ text: 'Hello World' \});await context.send(input);