MooseStack

Moose Workflows

Moose Workflows

Viewing:

Overview

The Workflows module provides standalone task orchestration and automation. You can use this capability independently to build ETL pipelines, run scheduled jobs, trigger background tasks, and manage long-running tasks without requiring other MooseStack components like databases or streams.

Basic Usage

Export Required

Ensure your Workflow and Task is correctly exported from your app/index.ts file.

Learn more about export pattern: local development / hosted.

DataFlow.ts
import { Task, Workflow } from "@514labs/moose-lib";
 
export interface Foo {
  name: string;
}
 
export interface Bar {
  name: string;
  greeting: string;
  counter: number;
}
 
export const task1 = new Task<Foo, Bar>("task1", {
  run: async (ctx) => {
    const greeting = `hello, ${ctx.input.name}!`;
    return {
      name: ctx.input.name,
      greeting,
      counter: 1
    };
  },
});
 
export const task2 = new Task<Bar, void>("task2", {
  run: async (ctx) => {
    console.log(`${ctx.input.greeting} (count: ${ctx.input.counter})`);
  },
});
 
export const myworkflow = new Workflow("myworkflow", {
  startingTask: task1
});
 

Enabling Workflows

To enable workflows, you need to add the workflows feature to your moose.config.toml file:

moose.config.toml
[features]
workflows = true

Core Capabilities

Definition

Define Workflows

Create workflow definitions with task sequences and data flow
Scheduling

Schedule Workflows

Set up recurring and scheduled workflow execution
Triggers

Trigger Workflows

Start workflows from events, APIs, or external triggers

Integration with Other Capabilities

While the Workflows capability works independently, it is designed to be used in conjunction with other MooseStack capabilities: