Skip to content

Instantly share code, notes, and snippets.

@teivah
Created May 30, 2018 13:38
Show Gist options
  • Select an option

  • Save teivah/a77bb8e9dd81b2745dc13e15b5407687 to your computer and use it in GitHub Desktop.

Select an option

Save teivah/a77bb8e9dd81b2745dc13e15b5407687 to your computer and use it in GitHub Desktop.
// Orchestration based on compose
private void method2() {
// Create first step
Future<String> future1 = readFile();
// Define future1 composition
future1.compose(s1 -> {
Future<String> future2 = writeFile(future1.result());
// Define future2 composition
future2.compose(s2 -> {
Future<String> future3 = copyFile(future2.result());
// Because the future3 is the last, we define here a handler
future3.setHandler(handler -> {
if (handler.succeeded()) {
System.out.println(handler.result());
} else {
// Manage doSmthg3 errors
}
});
} , Future.future().setHandler(handler -> {
// Manage doSmthg2 errors
}));
} , Future.future().setHandler(handler -> {
// Manage doSmthg1 errors
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment