Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active April 4, 2018 06:40
Show Gist options
  • Select an option

  • Save adamw/942022b7e7cd39243d0e80a5bf3e69bd to your computer and use it in GitHub Desktop.

Select an option

Save adamw/942022b7e7cd39243d0e80a5bf3e69bd to your computer and use it in GitHub Desktop.
class Synchronous {
// I/0 operations: blocking, synchronous
<T> T fetchFromDb(Class<T> entityClass, long id) { return null; }
String sendHttpGet(String url) { return null; }
void sendEmail(String to, String content) { }
// the business logic: synchronous
void runBusinessProcess() {
User user = fetchFromDb(User.class, 42);
String profile = sendHttpGet(
"http://profile_service/get/" + user.getProfileId());
sendEmail(user.getEmail(), "Your profile is: " + profile);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment