fanout

command
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

Fan-out Example — Concurrent Steps, First-of-N, Pending Approval

Shows the async RunStep model: check-inventory, quote-price, and manager-approval all start before anything is Get-ed. manager-approval suspends with ErrStepPending; main completes it from a separate goroutine, simulating a webhook. A select on Done() reacts to whichever of check-inventory / quote-price finishes first.

Run

go run .

Expected output

  → [check-inventory]   checking stock for order 7 …
  → [quote-price]       pricing order 7 …
  ⏸ [manager-approval]  suspended — waiting for CompleteStep
  ✓ [quote-price]       done
  ⚑ quote-price finished first

⏸  manager-approval is pending — completing it now (simulating a webhook) …
  ✓ [check-inventory]   in stock

✅  order processed: inventory=in-stock pricing=$42.00 approval=approved-by-manager

Run it again and the run is already StatusCompletedRunTask returns the stored output without invoking processOrder at all, and there is nothing to approve.

Reset

rm -rf examples/fanout/.data/

Documentation

Overview

Package main demonstrates durable-go's async RunStep fan-out: several steps run concurrently, joined with Get; a first-of-N select reacts to whichever of two steps finishes first; one step suspends with ErrStepPending and is resumed by an external CompleteStep call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL