Guest User

Untitled

a guest
Aug 17th, 2019
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Provide alternative method to execute when future failed
  3. */
  4. def fallbackTo(): Unit = {
  5. val f: Future[String] = downloadBlob("ftp://blobs/8671").fallbackTo {
  6. println(s"fetch from ftp")
  7. // fetch blob via ftp
  8. fetchBlob("ftp://blobs/8671")
  9. }
  10. println(Await.result(f, 10.seconds))
  11. }
  12.  
  13. /*
  14. * output
  15. fetch from ftp
  16. cmFoYXNhayBsYWJz
  17. */
RAW Paste Data