Skip to content

Ultra-Lightweight Durable Execution in TypeScript

License

Notifications You must be signed in to change notification settings

dbos-inc/dbos-transact-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBOS Transact: A Lightweight Durable Execution Library Built on Postgres

Documentation   •   Examples   •   Github   •   Discord


DBOS Transact is a TypeScript library for ultra-lightweight durable execution. For example:

class Example {
  @DBOS.step()
  static async step_one() {
    ...
  }

  @DBOS.step()
  static async step_two() {
    ...
  }

  @DBOS.workflow()
  static async workflow() {
    Example.step_one()
    Example.step_two()
  }
}

Durable execution means persisting the execution state of your program while it runs, so if it is ever interrupted or crashes, it automatically resumes from where it left off. Durable execution helps solve many common problems:

  • Orchestrating long-running or business-critical workflows so they seamlessly recover from any failure.
  • Running reliable background jobs with no timeouts.
  • Processing incoming events (e.g. from Kafka) exactly once.
  • Running a fault-tolerant distributed task queue.
  • Running a reliable cron scheduler.
  • Operating an AI agent, or anything that connects to an unreliable or non-deterministic API.

What’s unique about DBOS's implementation of durable execution is that it’s implemented in a lightweight library that’s totally backed by Postgres. To use DBOS, just npm install it and annotate your program with DBOS decorators. Under the hood, those decorators store your program's execution state (which workflows are currently executing and which steps they've completed) in a Postgres database. If your program crashes or is interrupted, they automatically recover its workflows from their stored state. So all you need to use DBOS is Postgres—there are no other dependencies you have to manage, no separate workflow server.

One big advantage of this approach is that you can add DBOS to any TypeScript application—it’s just a library. For example, you can use DBOS to add reliable background jobs or cron scheduling or queues to your Next.js app with no external dependencies except Postgres.

Getting Started

Initialize a starter app with:

npx @dbos-inc/create -t dbos-node-starter

Or, if you want to use the integration with Next.js:

npx @dbos-inc/create -t dbos-nextjs-starter

Then build and run your app with:

npm install
npm run build
npm run start

Visit your app in your browser at localhost:3000 to see durable execution in action!

To learn how to build more complex workflows, check out the programming guide or docs.

Documentation

https://docs.dbos.dev

Community

If you're interested in building with us, please star our repository and join our community on Discord! If you see a bug or have a feature request, don't hesitate to open an issue here on GitHub. If you're interested in contributing, check out our contributions guide.