Skip to main content

Interruptible execution

Stop or redirect long work gracefully based on durable control signals.

Problem and approach

Here we demonstrate an Interruptible Flow Pattern implemented using the Dex. This pattern demonstrates how Flows can be designed to handle interruptions gracefully, allowing for dynamic control over Flow execution.

Overview

The Interruptible Flow Pattern allows a Flow to be interrupted and gracefully terminated based on external signals. This is particularly useful in scenarios where long-running tasks may need to be stopped due to changing requirements or external conditions.

Key Components

  1. InterruptibleExecutionFlow: The main Flow class that defines the Steps and handles interruptions.
  2. InitStep: The initial Step that sets up the Flow and transitions to execution Steps.
  3. WorkAExecutionStep and WorkNExecutionStep: Execution Steps that perform tasks and check for interrupt signals.

Code examples

Full runnable samples live under examples/{go,java,python,typescript} (HTTP prefix /design-pattern/... where applicable).

# See examples/python/dex_examples/patterns/workflow/interruptible/