Skip to content

Instantly share code, notes, and snippets.

@tteggel
Last active November 22, 2017 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tteggel/39919fe5eae36b73a7ba564040f036c5 to your computer and use it in GitHub Desktop.
Save tteggel/39919fe5eae36b73a7ba564040f036c5 to your computer and use it in GitHub Desktop.
Serverless Sagas with Fn Flow
public void book1(TripReq input) {
Flow f = Flows.currentFlow();
FlowFuture<BookingRes> flightFuture =
f.invokeFunction("./flight/book", input.flight, BookingRes.class);
FlowFuture<BookingRes> hotelFuture =
f.invokeFunction("./hotel/book", input.hotel, BookingRes.class);
FlowFuture<BookingRes> carFuture =
f.invokeFunction("./car/book", input.carRental, BookingRes.class);
flightFuture.thenCompose(
(flightRes) -> hotelFuture.thenCompose(
(hotelRes) -> carFuture.whenComplete(
(carRes, e) -> EmailReq.sendSuccessMail(flightRes, hotelRes, carRes)
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment