Documentation
¶
Overview ¶
Command trip-booking shows child workflows running in parallel and a saga: when one leg of a trip can't be booked, the workflow compensates by cancelling the leg that already succeeded, then completes with a domain result rather than failing.
DATABASE_URL=postgres://localhost:5432/river_dev?sslmode=disable \
go run ./examples/trip-booking
The parent "book-trip" starts two child workflows — "book-flight" and "book-hotel" — in parallel. Because either may commit a booking before the other finishes, the parent awaits BOTH outcomes before deciding: if exactly one failed, it cancels the booking the other already made. (Awaiting just the first and returning on its error would strand a booking the second leg had made — the classic parallel-saga bug.) The workflow only fails if a compensation itself fails; every business outcome completes with a result.
A child workflow that fails surfaces at Get as an *ActivityError, the same as a failed activity.