{"action":"created","comment":{"url":"https://api.github.com/repos/scala-academy/castalia/pulls/comments/52120253","id":52120253,"diff_hunk":"@@ -0,0 +1,62 @@\n+package castalia.matcher\n+\n+import akka.actor._\n+import akka.http.scaladsl.model.StatusCodes._\n+import akka.pattern.{ask, pipe}\n+import akka.util.Timeout\n+import castalia.matcher.MatchResultGatherer.{MatchFound, MatchNotFound}\n+import castalia.model.Model.StubResponse\n+\n+import scala.concurrent.ExecutionContext.Implicits.global\n+import scala.concurrent.duration._\n+\n+/**\n+  * Created by Jordi on 4-2-2016.\n+  */\n+object MatchResultGatherer {\n+\n+  case object MatchNotFound\n+\n+  case class MatchFound(stubHandler: ActorRef, requestMatch: RequestMatch)\n+\n+  def props(nOfMatchers: Int, origin: ActorRef): Props = Props(new MatchResultGatherer(nOfMatchers, origin))\n+}\n+\n+class MatchResultGatherer(nrOfMatchers: Int, origin: ActorRef) extends Actor with ActorLogging {\n+  implicit val timeout = Timeout(2.seconds)\n+\n+  def receive: Receive = awaitResponses(false, nrOfMatchers)\n+\n+  def awaitResponses(responseSent: Boolean, responsesToGet: Int): Receive = {\n+    case MatchNotFound =>\n+      handleMatchNotFound(responseSent, responsesToGet)\n+    case MatchFound(handler, requestMatch) =>\n+      handleMatchFound(responseSent, responsesToGet, handler, requestMatch)\n+  }\n+\n+  def handleMatchNotFound(responseSent: Boolean, responsesToGet: Int): Unit = {\n+    if (responsesToGet > 1) {","path":"src/main/scala/castalia/matcher/MatchResultGatherer.scala","position":38,"original_position":38,"commit_id":"59721fd0a1ee52529d051dd84693cd22e3bbc903","original_commit_id":"59721fd0a1ee52529d051dd84693cd22e3bbc903","user":{"login":"TimSoethout","id":593132,"avatar_url":"https://avatars.githubusercontent.com/u/593132?v=3","gravatar_id":"","url":"https://api.github.com/users/TimSoethout","html_url":"https://github.com/TimSoethout","followers_url":"https://api.github.com/users/TimSoethout/followers","following_url":"https://api.github.com/users/TimSoethout/following{/other_user}","gists_url":"https://api.github.com/users/TimSoethout/gists{/gist_id}","starred_url":"https://api.github.com/users/TimSoethout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimSoethout/subscriptions","organizations_url":"https://api.github.com/users/TimSoethout/orgs","repos_url":"https://api.github.com/users/TimSoethout/repos","events_url":"https://api.github.com/users/TimSoethout/events{/privacy}","received_events_url":"https://api.github.com/users/TimSoethout/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/versioned/images/favicon.png) Issue found: [Consider using case matching instead of else if blocks](https://www.codacy.com/app/scala-academy/Castalia/file/1993124804/issues/source?bid=2998213&fileBranchId=3120054#l38)","created_at":"2016-02-07T16:49:15Z","updated_at":"2016-02-07T16:49:15Z","html_url":"https://github.com/scala-academy/castalia/pull/60#discussion_r52120253","pull_request_url":"https://api.github.com/repos/scala-academy/castalia/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/comments/52120253"},"html":{"href":"https://github.com/scala-academy/castalia/pull/60#discussion_r52120253"},"pull_request":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/scala-academy/castalia/pulls/60","id":58546025,"html_url":"https://github.com/scala-academy/castalia/pull/60","diff_url":"https://github.com/scala-academy/castalia/pull/60.diff","patch_url":"https://github.com/scala-academy/castalia/pull/60.patch","issue_url":"https://api.github.com/repos/scala-academy/castalia/issues/60","number":60,"state":"open","locked":false,"title":"Feature/distributedmatching","user":{"login":"jordi133","id":6985599,"avatar_url":"https://avatars.githubusercontent.com/u/6985599?v=3","gravatar_id":"","url":"https://api.github.com/users/jordi133","html_url":"https://github.com/jordi133","followers_url":"https://api.github.com/users/jordi133/followers","following_url":"https://api.github.com/users/jordi133/following{/other_user}","gists_url":"https://api.github.com/users/jordi133/gists{/gist_id}","starred_url":"https://api.github.com/users/jordi133/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordi133/subscriptions","organizations_url":"https://api.github.com/users/jordi133/orgs","repos_url":"https://api.github.com/users/jordi133/repos","events_url":"https://api.github.com/users/jordi133/events{/privacy}","received_events_url":"https://api.github.com/users/jordi133/received_events","type":"User","site_admin":false},"body":"Refactored the matching algorithm to let multiple endpoint matchers be executed in parallel using actors. Looks to be performing better now.","created_at":"2016-02-07T13:04:13Z","updated_at":"2016-02-07T16:49:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"574858eeb4e38b96d4e3e732eafea51d043a1da4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scala-academy/castalia/pulls/60/commits","review_comments_url":"https://api.github.com/repos/scala-academy/castalia/pulls/60/comments","review_comment_url":"https://api.github.com/repos/scala-academy/castalia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala-academy/castalia/issues/60/comments","statuses_url":"https://api.github.com/repos/scala-academy/castalia/statuses/59721fd0a1ee52529d051dd84693cd22e3bbc903","head":{"label":"scala-academy:feature/distributedmatching","ref":"feature/distributedmatching","sha":"59721fd0a1ee52529d051dd84693cd22e3bbc903","user":{"login":"scala-academy","id":15196297,"avatar_url":"https://avatars.githubusercontent.com/u/15196297?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-academy","html_url":"https://github.com/scala-academy","followers_url":"https://api.github.com/users/scala-academy/followers","following_url":"https://api.github.com/users/scala-academy/following{/other_user}","gists_url":"https://api.github.com/users/scala-academy/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-academy/subscriptions","organizations_url":"https://api.github.com/users/scala-academy/orgs","repos_url":"https://api.github.com/users/scala-academy/repos","events_url":"https://api.github.com/users/scala-academy/events{/privacy}","received_events_url":"https://api.github.com/users/scala-academy/received_events","type":"Organization","site_admin":false},"repo":{"id":43876154,"name":"castalia","full_name":"scala-academy/castalia","owner":{"login":"scala-academy","id":15196297,"avatar_url":"https://avatars.githubusercontent.com/u/15196297?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-academy","html_url":"https://github.com/scala-academy","followers_url":"https://api.github.com/users/scala-academy/followers","following_url":"https://api.github.com/users/scala-academy/following{/other_user}","gists_url":"https://api.github.com/users/scala-academy/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-academy/subscriptions","organizations_url":"https://api.github.com/users/scala-academy/orgs","repos_url":"https://api.github.com/users/scala-academy/repos","events_url":"https://api.github.com/users/scala-academy/events{/privacy}","received_events_url":"https://api.github.com/users/scala-academy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-academy/castalia","description":"API stub server","fork":false,"url":"https://api.github.com/repos/scala-academy/castalia","forks_url":"https://api.github.com/repos/scala-academy/castalia/forks","keys_url":"https://api.github.com/repos/scala-academy/castalia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-academy/castalia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-academy/castalia/teams","hooks_url":"https://api.github.com/repos/scala-academy/castalia/hooks","issue_events_url":"https://api.github.com/repos/scala-academy/castalia/issues/events{/number}","events_url":"https://api.github.com/repos/scala-academy/castalia/events","assignees_url":"https://api.github.com/repos/scala-academy/castalia/assignees{/user}","branches_url":"https://api.github.com/repos/scala-academy/castalia/branches{/branch}","tags_url":"https://api.github.com/repos/scala-academy/castalia/tags","blobs_url":"https://api.github.com/repos/scala-academy/castalia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-academy/castalia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-academy/castalia/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-academy/castalia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-academy/castalia/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-academy/castalia/languages","stargazers_url":"https://api.github.com/repos/scala-academy/castalia/stargazers","contributors_url":"https://api.github.com/repos/scala-academy/castalia/contributors","subscribers_url":"https://api.github.com/repos/scala-academy/castalia/subscribers","subscription_url":"https://api.github.com/repos/scala-academy/castalia/subscription","commits_url":"https://api.github.com/repos/scala-academy/castalia/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-academy/castalia/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-academy/castalia/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-academy/castalia/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-academy/castalia/contents/{+path}","compare_url":"https://api.github.com/repos/scala-academy/castalia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-academy/castalia/merges","archive_url":"https://api.github.com/repos/scala-academy/castalia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-academy/castalia/downloads","issues_url":"https://api.github.com/repos/scala-academy/castalia/issues{/number}","pulls_url":"https://api.github.com/repos/scala-academy/castalia/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-academy/castalia/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-academy/castalia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-academy/castalia/labels{/name}","releases_url":"https://api.github.com/repos/scala-academy/castalia/releases{/id}","deployments_url":"https://api.github.com/repos/scala-academy/castalia/deployments","created_at":"2015-10-08T09:07:23Z","updated_at":"2016-01-12T19:43:21Z","pushed_at":"2016-02-07T16:46:10Z","git_url":"git://github.com/scala-academy/castalia.git","ssh_url":"git@github.com:scala-academy/castalia.git","clone_url":"https://github.com/scala-academy/castalia.git","svn_url":"https://github.com/scala-academy/castalia","homepage":"","size":1651,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":11,"forks":3,"open_issues":11,"watchers":4,"default_branch":"develop"}},"base":{"label":"scala-academy:develop","ref":"develop","sha":"674f934f9a59a7ecc36477a87117f8e7c2f8e376","user":{"login":"scala-academy","id":15196297,"avatar_url":"https://avatars.githubusercontent.com/u/15196297?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-academy","html_url":"https://github.com/scala-academy","followers_url":"https://api.github.com/users/scala-academy/followers","following_url":"https://api.github.com/users/scala-academy/following{/other_user}","gists_url":"https://api.github.com/users/scala-academy/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-academy/subscriptions","organizations_url":"https://api.github.com/users/scala-academy/orgs","repos_url":"https://api.github.com/users/scala-academy/repos","events_url":"https://api.github.com/users/scala-academy/events{/privacy}","received_events_url":"https://api.github.com/users/scala-academy/received_events","type":"Organization","site_admin":false},"repo":{"id":43876154,"name":"castalia","full_name":"scala-academy/castalia","owner":{"login":"scala-academy","id":15196297,"avatar_url":"https://avatars.githubusercontent.com/u/15196297?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-academy","html_url":"https://github.com/scala-academy","followers_url":"https://api.github.com/users/scala-academy/followers","following_url":"https://api.github.com/users/scala-academy/following{/other_user}","gists_url":"https://api.github.com/users/scala-academy/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-academy/subscriptions","organizations_url":"https://api.github.com/users/scala-academy/orgs","repos_url":"https://api.github.com/users/scala-academy/repos","events_url":"https://api.github.com/users/scala-academy/events{/privacy}","received_events_url":"https://api.github.com/users/scala-academy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-academy/castalia","description":"API stub server","fork":false,"url":"https://api.github.com/repos/scala-academy/castalia","forks_url":"https://api.github.com/repos/scala-academy/castalia/forks","keys_url":"https://api.github.com/repos/scala-academy/castalia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-academy/castalia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-academy/castalia/teams","hooks_url":"https://api.github.com/repos/scala-academy/castalia/hooks","issue_events_url":"https://api.github.com/repos/scala-academy/castalia/issues/events{/number}","events_url":"https://api.github.com/repos/scala-academy/castalia/events","assignees_url":"https://api.github.com/repos/scala-academy/castalia/assignees{/user}","branches_url":"https://api.github.com/repos/scala-academy/castalia/branches{/branch}","tags_url":"https://api.github.com/repos/scala-academy/castalia/tags","blobs_url":"https://api.github.com/repos/scala-academy/castalia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-academy/castalia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-academy/castalia/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-academy/castalia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-academy/castalia/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-academy/castalia/languages","stargazers_url":"https://api.github.com/repos/scala-academy/castalia/stargazers","contributors_url":"https://api.github.com/repos/scala-academy/castalia/contributors","subscribers_url":"https://api.github.com/repos/scala-academy/castalia/subscribers","subscription_url":"https://api.github.com/repos/scala-academy/castalia/subscription","commits_url":"https://api.github.com/repos/scala-academy/castalia/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-academy/castalia/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-academy/castalia/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-academy/castalia/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-academy/castalia/contents/{+path}","compare_url":"https://api.github.com/repos/scala-academy/castalia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-academy/castalia/merges","archive_url":"https://api.github.com/repos/scala-academy/castalia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-academy/castalia/downloads","issues_url":"https://api.github.com/repos/scala-academy/castalia/issues{/number}","pulls_url":"https://api.github.com/repos/scala-academy/castalia/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-academy/castalia/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-academy/castalia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-academy/castalia/labels{/name}","releases_url":"https://api.github.com/repos/scala-academy/castalia/releases{/id}","deployments_url":"https://api.github.com/repos/scala-academy/castalia/deployments","created_at":"2015-10-08T09:07:23Z","updated_at":"2016-01-12T19:43:21Z","pushed_at":"2016-02-07T16:46:10Z","git_url":"git://github.com/scala-academy/castalia.git","ssh_url":"git@github.com:scala-academy/castalia.git","clone_url":"https://github.com/scala-academy/castalia.git","svn_url":"https://github.com/scala-academy/castalia","homepage":"","size":1651,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":11,"forks":3,"open_issues":11,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/60"},"html":{"href":"https://github.com/scala-academy/castalia/pull/60"},"issue":{"href":"https://api.github.com/repos/scala-academy/castalia/issues/60"},"comments":{"href":"https://api.github.com/repos/scala-academy/castalia/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala-academy/castalia/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/scala-academy/castalia/statuses/59721fd0a1ee52529d051dd84693cd22e3bbc903"}}}}