How do I run a workflow that compensates?

Table of Contents

The saga configuration of the identity workflow. The ores-shell block below is tangled into the runnable script library as identity_saga.ores.

1. Question

How do I exercise the engine's rollback path?

2. Answer

The first step declares a compensation; the second fails. The engine dispatches the compensation for the completed step, records it at a negative step index, and settles the instance at compensated once every rollback has finished.

workflow start identity_workflow '{"steps":[{"name":"ok","compensate":true},{"name":"boom","behaviour":"fail"}]}' --instance-id 10000000-0000-4000-8000-000000000005
workflow wait 10000000-0000-4000-8000-000000000005 --timeout 60 --expect-state compensated

workflow wait fails unless the instance reaches the state named, so this script fails when the path it covers does nothing.

3. Script

projects/ores.shell/scripts/library/workflow/identity_saga.ores – generated from this recipe by compass build --direct tangle_shell_scripts (do not edit the .ores by hand).

4. Tested by

Manual: compass shell -f identity_saga.ores against a running fleet.

5. See also

Emacs 29.3 (Org mode 9.6.15)