Created
May 30, 2018 13:38
-
-
Save teivah/a77bb8e9dd81b2745dc13e15b5407687 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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