We value your privacy

This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content. See our Privacy Policy.

  1. MooseStack
  2. Moose Workflows

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.

app/report-workflow.ts
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.

moose.config.toml
[features]workflows = true

What 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
Start here if the workflow should run automatically on a recurring cadence.
Schedule a workflow →
Trigger work from an API or event
Start here if another system or request path should kick off the workflow.
Trigger a workflow →

Related resources

  • Define workflows
  • Schedule workflows
  • Trigger workflow
  • Retries and timeouts
  • Cancel workflow
  • Insert data when workflow output should land in Moose OLAP

On this page

What can you do with Moose Workflows?Define durable background workStart work on a schedule or from eventsControl long-running executionGet StartedRelated resources
Edit this page
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackHostingTemplatesGuides
Release Notes
Source575
  • Overview
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Language Server
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streams
  • Moose Workflows
  • Moose APIs & Web Apps
Deployment & Lifecycle
  • Moose Dev
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Query Layer
  • Testing Utilities
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework
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.

app/report-workflow.ts
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,});