Skip to content

Instantly share code, notes, and snippets.

@knightpop
Last active November 5, 2017 14:11
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 knightpop/842e4e2d8017884b5ce9ea12c18b3a16 to your computer and use it in GitHub Desktop.
Save knightpop/842e4e2d8017884b5ce9ea12c18b3a16 to your computer and use it in GitHub Desktop.
case class UserInfo(userId: Int, nickname: String, emailAddress: String, account: Option[Long])
def getNicknameById(userId: Int): Future[String] = Future {
Thread.sleep(2000)
"ktz"
}
def getEmailAddressByNickname(nickname: String): Future[String] = Future {
Thread.sleep(2000)
"helloworld@example.com"
}
def getAccountInfoByNickname(nickname: String): Future[Option[Long]] = Future {
Thread.sleep(3000)
None
}
def printInterval(userInfo: UserInfo, start: Instant, end: Instant): String =
s"$userInfo take ${(end.toEpochMilli - start.toEpochMilli) / 1000} seconds"
val userId: Int = 31337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment