trip-booking

command
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 12 Imported by: 0

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.

Jump to

Keyboard shortcuts

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