---
title: "Building Workflows, Part 2 – the executor and evaluation"
description: "incident.io's workflow executor listens for trigger events, evaluates workflow conditions against a scope, and creates a workflow run before executing steps."
url: "https://swe.quest/articles/building-workflows-part-2-the-executor-and-evaluation-b966efc6ca5866f8"
canonical: "https://incident.io/blog/building-workflows-part-2"
source: "incident.io"
published: "2022-09-14"
difficulty: "medium"
kind: "Case study"
reading_minutes: 19
tags: ["postgres","scheduling","messaging","system-design","go"]
---

# Building Workflows, Part 2 – the executor and evaluation

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2022-09-14, 19 min read, Case study. Original: [https://incident.io/blog/building-workflows-part-2](https://incident.io/blog/building-workflows-part-2)

## Summary

incident.io's workflow executor listens for trigger events, evaluates workflow conditions against a scope, and creates a workflow run before executing steps. A broad 'incident-updated' trigger fixes ordering problems with multi-condition workflows. A 'once-for' column backed by a Postgres unique index provides cheap, consistent idempotency, so trigger consumers can be retried safely. To cope with Google Pub/Sub's at-least-once delivery, execution proceeds one step at a time under a SELECT FOR UPDATE row lock, with a JSON progress column recording completed steps. Runs therefore behave serially, resume after crashes without repeating steps, and double as a customer-facing audit log.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Scheduling](https://swe.quest/tags/scheduling.md) (Distributed systems)
- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Go](https://swe.quest/tags/go.md) (Languages)

## Prerequisites

- Postgres row locking ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- message queue delivery semantics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- relational data modeling

## Keywords

incident.io, Google Pub/Sub, PostgreSQL, GORM, PagerDuty

## Related posts

- [Running Durable Workflows in Postgres using DBOS](https://swe.quest/articles/running-durable-workflows-in-postgres-using-dbos-758f463809fa3e9f.md): Supabase · 2024-12-10 · Medium · 4 min read · PostgreSQL, Scheduling, Resilience, Serverless
  DBOS implements durable workflows entirely in Postgres: workflow and step decorators record a workflow's ID, inputs and status in a workflow\_status table and each step's output in operation\_outputs, all within a separate system database.
- [Workflows are coming to Supabase](https://swe.quest/articles/workflows-are-coming-to-supabase-a57ed34660f0256b.md): Supabase · 2021-04-02 · Medium · 5 min read · Serverless, PostgreSQL, Elixir & Erlang, Scheduling, Event-driven architecture
  Supabase is building Workflows, an open source orchestration engine written in Elixir that uses the Amazon States Language to coordinate existing functions (AWS, GCP, Azure, OpenFaaS, Postgres) in response to database events or HTTP calls.
- [Durable and auditable workflows with DBOS and ClickHouse Managed Postgres](https://swe.quest/articles/durable-and-auditable-workflows-with-dbos-and-clickhouse-managed-postgres-84b2cf91df44a544.md): ClickHouse · 2026-11-24 · Medium · 6 min read · Event-driven architecture, PostgreSQL, Analytics & OLAP, Scheduling, Python
  DBOS, an open-source Postgres-native durable execution library, stores workflow and step checkpoints, queues and schedules in Postgres so crashed processes resume from the last completed step without a separate orchestrator.
- [Postgres as Your Platform: Building Event-Driven Systems with Schema Changes](https://swe.quest/articles/postgres-as-your-platform-building-event-driven-systems-with-schema-changes-6824bf4fc3fb4dca.md): Neon · 2025-07-25 · Medium · 7 min read · PostgreSQL, Event-driven architecture, Schema migrations, Multi-tenancy
  Postgres event triggers, transactional DDL and LISTEN/NOTIFY can turn schema changes into reliable events that drive downstream automation such as SDK generation, warehouse syncs and documentation updates, with no external queue.
- [Service disruption on October 20, 2025](https://swe.quest/articles/service-disruption-on-october-20-2025-fe786fa7dabbc413.md): incident.io · 2025-10-22 · Medium · 12 min read · Incidents & postmortems, Resilience, PostgreSQL, CI/CD, Cloud platforms
  The October 20, 2025 AWS us-east-1 outage degraded incident.io through third-party dependencies even though it runs on Google Cloud: its transcription, SAML, telecom and status page providers were all affected.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
