Skip to content

Instantly share code, notes, and snippets.

@pawelkaczor
Last active October 31, 2016 16:41
Show Gist options
  • Save pawelkaczor/2637975e6337666cc7ac6a8679cadd21 to your computer and use it in GitHub Desktop.
Save pawelkaczor/2637975e6337666cc7ac6a8679cadd21 to your computer and use it in GitHub Desktop.
startWhen {
case _: ReservationConfirmed => New
} andThen {
case New => {
case ReservationConfirmed(reservationId, customerId, totalAmount) =>
WaitingForPayment {
⟶ (CreateInvoice(sagaId, reservationId, customerId, totalAmount, now()))
⟵ (PaymentExpired(sagaId, reservationId)) in 3.minutes
}
}
case WaitingForPayment => {
case PaymentExpired(invoiceId, orderId) =>
⟶ (CancelInvoice(invoiceId, orderId))
case OrderBilled(_, orderId, _, _) =>
DeliveryInProgress {
⟶ (CloseReservation(orderId))
⟶ (CreateShipment(UUID(), orderId))
}
case OrderBillingFailed(_, orderId) =>
Failed {
⟶ (CancelReservation(orderId))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment