Moose Workflows
Moose Workflows adds durable background processing around Moose OLAP. Use it for scheduled jobs, backfills, external calls, or multi-step tasks that should run reliably outside the request path.
Export Required
Moose only discovers resource definitions through your root app/index.ts barrel file. Re-export the Workflow and Task shown here from that file or Moose will not pick up those definitions.
TypeScript example: export { myworkflow, prepareReport, persistReport }
Learn more about resource discovery: local development / hosted.
import { Task, Workflow } from "@514labs/moose-lib"; interface ReportRequest { reportDate: string;} interface ReportResult { reportDate: string; status: "ready";} export const persistReport = new Task<ReportResult, void>("persist_report", { run: async (ctx) => { console.log(`Persisted report for ${ctx.input.reportDate}`); },}); export const prepareReport = new Task<ReportRequest, ReportResult>("prepare_report", { run: async (ctx) => ({ reportDate: ctx.input.reportDate, status: "ready", }), onComplete: [persistReport],}); export const myworkflow = new Workflow("daily_report", { startingTask: prepareReport,});Workflows usually complement other Moose modules rather than replace them. A common pattern is to schedule or trigger work that reads from Moose OLAP, writes new records, or coordinates external systems around your data model.
Enable workflows before defining them
Turn on features.workflows in moose.config.toml before you create Workflow and Task resources.
[features]workflows = trueWhat can you do with Moose Workflows?
Define durable background work
- Define workflows with typed tasks and explicit sequencing
Start work on a schedule or from events
- Schedule workflows for recurring jobs such as daily refreshes or hourly syncs
- Trigger workflows from APIs, operators, or other systems
Control long-running execution
- Set retries and timeouts for failure handling and runtime limits
- Cancel running workflows when work should stop early
Get Started
Run work on a schedule
Trigger work from an API or event
Related resources
- Define workflows
- Schedule workflows
- Trigger workflow
- Retries and timeouts
- Cancel workflow
- Insert data when workflow output should land in Moose OLAP