Last active
August 29, 2015 14:26
-
-
Save dhoss/1b71b00a94ac5120e556 to your computer and use it in GitHub Desktop.
need to retain the repository name as well as the WSResponse
This file contains 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
case class RepositoryCommitResponse(repository: String, response: Future[WSResponse]) | |
val repos = reposFor(project) // just a list of strings: List("repo1", "repo2", "repo3") | |
val futureRepoList = repos.map { repo => Future{RepositoryCommitResponse(repo, callApi(buildCommitUrl(project, repo)))} } | |
Logger.info("FUTURE REPO LIST " + futureRepoList) | |
val goodRepos = Future.sequence(futureRepoList) map { fr => | |
fr.map(_.response.filter(_.status==200)) | |
} | |
for ( r <- goodRepos ) { | |
for (rr <- r) { | |
Logger.info("GOOD REPOS " + Await.result(rr, Duration.Inf)) | |
} | |
} | |
/********* | |
* Output: | |
* [info] - application - FUTURE REPO LIST List(scala.concurrent.impl.Promise$DefaultPromise@4a5c20b0, scala.concurrent.impl.Promise$DefaultPromise@31757746, scala.concurrent.impl.Promise$DefaultPromise@7e874761, scala.concurrent.impl.Promise$DefaultPromise@4a010dcb, scala.concurrent.impl.Promise$DefaultPromise@6173ed9b) | |
* [info] - application - GOOD REPOS NingWSResponse(200, OK) | |
* [info] - application - GOOD REPOS NingWSResponse(200, OK) | |
* [info] - application - GOOD REPOS NingWSResponse(200, OK) | |
* [info] - application - GOOD REPOS NingWSResponse(200, OK) | |
* [info] - application - GOOD REPOS NingWSResponse(200, OK) | |
********* | |
* I would like it to look something like RepositoryCommitResponse("repoName", NingWSResponse(200, OK)) | |
*********/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment