-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I am trying to call two workflows inside scheduled handler inside worker:
const workflows = {
onChainWorkflow,
macroWorkflow,
} as const;First approach (here only the first one is fired):
async scheduled(event, env, ctx): Promise<void> {
const taskId = `sentiment-${Date.now()}`;
const id = env.WORKFLOWS.idFromName(taskId);
const stub = env.WORKFLOWS.get(id);
const onChainResult = await stub.run({
workflow: "onChainWorkflow",
input: `onchain-${taskId}`,
});
console.log(`trigger fired at ${event.cron}: ${onChainResult.id}`);
const macroResult = await stub.run({
workflow: "macroWorkflow",
input: `macro-${taskId}`,
});
console.log(`trigger fired at ${event.cron}: ${macroResult.id}`);
}Second approach (don't know how to call second one):
async scheduled(event, env, ctx): Promise<void> {
const clientOnChain = WorkflowClient.fromBinding(env.WORKFLOWS);
const taskId = `sentiment-${Date.now()}`;
const { id } = await Effect.runPromise(
clientOnChain.runAsync({
workflow: "onChainWorkflow",
input: `onchain-${taskId}`
})
);
console.log(`trigger fired at ${event.cron}: ${id}`);
}or maybe I should do this differently or such scenario is not supported? What I am going to achieve is to split workflows which contain many steps into smaller, call smaller in scheduled handler and allow to call each workflow on demand (probably as hono endpoint, like in the example).
Metadata
Metadata
Assignees
Labels
No labels