{"action":"created","comment":{"url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/comments/130923927","pull_request_review_id":53852550,"id":130923927,"diff_hunk":"@@ -64,6 +60,19 @@ trait WaitForTaskDsl {\n   implicit object WaitForTaskDefinitionExecutable\n       extends Executable[WaitForTaskDefinition, TaskStatus] {\n \n+    // Run every 50 ms, use a wheel with 512 buckets\n+    private lazy val timer = {\n+      val threadFactory = new ThreadFactory {","path":"src/main/scala/algolia/definitions/WaitForTaskDefinition.scala","position":37,"original_position":37,"commit_id":"56299258c124101e0bb90669a1f801ca53d8f701","original_commit_id":"400120d0ef1115488df6b8efe5711bcf52c9d32c","user":{"login":"ElPicador","id":16667,"avatar_url":"https://avatars1.githubusercontent.com/u/16667?v=4","gravatar_id":"","url":"https://api.github.com/users/ElPicador","html_url":"https://github.com/ElPicador","followers_url":"https://api.github.com/users/ElPicador/followers","following_url":"https://api.github.com/users/ElPicador/following{/other_user}","gists_url":"https://api.github.com/users/ElPicador/gists{/gist_id}","starred_url":"https://api.github.com/users/ElPicador/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElPicador/subscriptions","organizations_url":"https://api.github.com/users/ElPicador/orgs","repos_url":"https://api.github.com/users/ElPicador/repos","events_url":"https://api.github.com/users/ElPicador/events{/privacy}","received_events_url":"https://api.github.com/users/ElPicador/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2017-08-02T16:17:15Z","updated_at":"2017-08-02T16:17:15Z","html_url":"https://github.com/algolia/algoliasearch-client-scala/pull/393#discussion_r130923927","pull_request_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393","_links":{"self":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/comments/130923927"},"html":{"href":"https://github.com/algolia/algoliasearch-client-scala/pull/393#discussion_r130923927"},"pull_request":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393"}}},"pull_request":{"url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393","id":133575372,"html_url":"https://github.com/algolia/algoliasearch-client-scala/pull/393","diff_url":"https://github.com/algolia/algoliasearch-client-scala/pull/393.diff","patch_url":"https://github.com/algolia/algoliasearch-client-scala/pull/393.patch","issue_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/393","number":393,"state":"open","locked":false,"title":"Add tasks status definition + use HashedWheelTimer in waitFor","user":{"login":"jlogeart","id":4989701,"avatar_url":"https://avatars2.githubusercontent.com/u/4989701?v=4","gravatar_id":"","url":"https://api.github.com/users/jlogeart","html_url":"https://github.com/jlogeart","followers_url":"https://api.github.com/users/jlogeart/followers","following_url":"https://api.github.com/users/jlogeart/following{/other_user}","gists_url":"https://api.github.com/users/jlogeart/gists{/gist_id}","starred_url":"https://api.github.com/users/jlogeart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlogeart/subscriptions","organizations_url":"https://api.github.com/users/jlogeart/orgs","repos_url":"https://api.github.com/users/jlogeart/repos","events_url":"https://api.github.com/users/jlogeart/events{/privacy}","received_events_url":"https://api.github.com/users/jlogeart/received_events","type":"User","site_admin":false},"body":"This PR makes two changes:\r\n\r\n- Adds a `TaskStatusDefinition` to simply query the status of task without waiting for it\r\n- In the `WaitForTaskDefinition`, replaces the creation of `Timer` with a `HashedWheelTimer`\r\n\r\nThe motivation of the first change is to allow the caller to handle the retries (if any) instead of imposing a strategy. It also allows **not** to create a new `Timer` (and therefore a new `Thread`) for each call.\r\n\r\nThe motivation of the second change is to allow multiple `waitFors` without creating new timer `Threads` for each one. \r\n\r\nAt [Flow](https://github.com/flowcommerce), we ran into issues while checking the status of multiple index tasks with aggressive `baseDelay` as it ended up creating several thousands of `Threads`. The recursive implementation of the `WaitForTaskDsl.request` allows for the creation of several `Threads` per `waitFor` call. In our case, it lead to `java.lang.OutOfMemoryError: unable to create new native thread`.\r\n\r\nI understand we do not want to encourage clients to issue thousand of calls at once but again in our case, a few `waitFors` with short `baseDelay` lead to the creation of several thousands threads and eventually to a painful death ;-)\r\n\r\nSince extreme time precision is not a requirement, the proposed solution therefore uses a `HashedWheelTimer` with a tick duration of 50ms. This number is roughly in the order of a network round trip. That would allow to defer the calls to the underlying http client.\r\n\r\nPlease feel free to modify :)\r\n\r\n","created_at":"2017-08-01T21:23:44Z","updated_at":"2017-08-02T16:17:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0a1da5e329e18bfcffc2c9e480cc240a17b1b15","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393/commits","review_comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393/comments","review_comment_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/393/comments","statuses_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/statuses/56299258c124101e0bb90669a1f801ca53d8f701","head":{"label":"jlogeart:feature/status-wait","ref":"feature/status-wait","sha":"56299258c124101e0bb90669a1f801ca53d8f701","user":{"login":"jlogeart","id":4989701,"avatar_url":"https://avatars2.githubusercontent.com/u/4989701?v=4","gravatar_id":"","url":"https://api.github.com/users/jlogeart","html_url":"https://github.com/jlogeart","followers_url":"https://api.github.com/users/jlogeart/followers","following_url":"https://api.github.com/users/jlogeart/following{/other_user}","gists_url":"https://api.github.com/users/jlogeart/gists{/gist_id}","starred_url":"https://api.github.com/users/jlogeart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlogeart/subscriptions","organizations_url":"https://api.github.com/users/jlogeart/orgs","repos_url":"https://api.github.com/users/jlogeart/repos","events_url":"https://api.github.com/users/jlogeart/events{/privacy}","received_events_url":"https://api.github.com/users/jlogeart/received_events","type":"User","site_admin":false},"repo":{"id":97989456,"name":"algoliasearch-client-scala","full_name":"jlogeart/algoliasearch-client-scala","owner":{"login":"jlogeart","id":4989701,"avatar_url":"https://avatars2.githubusercontent.com/u/4989701?v=4","gravatar_id":"","url":"https://api.github.com/users/jlogeart","html_url":"https://github.com/jlogeart","followers_url":"https://api.github.com/users/jlogeart/followers","following_url":"https://api.github.com/users/jlogeart/following{/other_user}","gists_url":"https://api.github.com/users/jlogeart/gists{/gist_id}","starred_url":"https://api.github.com/users/jlogeart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlogeart/subscriptions","organizations_url":"https://api.github.com/users/jlogeart/orgs","repos_url":"https://api.github.com/users/jlogeart/repos","events_url":"https://api.github.com/users/jlogeart/events{/privacy}","received_events_url":"https://api.github.com/users/jlogeart/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jlogeart/algoliasearch-client-scala","description":"Algolia Search API Client for Scala 2.11","fork":true,"url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala","forks_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/forks","keys_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/teams","hooks_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/hooks","issue_events_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/issues/events{/number}","events_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/events","assignees_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/assignees{/user}","branches_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/branches{/branch}","tags_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/tags","blobs_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/statuses/{sha}","languages_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/languages","stargazers_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/stargazers","contributors_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/contributors","subscribers_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/subscribers","subscription_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/subscription","commits_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/contents/{+path}","compare_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/merges","archive_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/downloads","issues_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/issues{/number}","pulls_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/pulls{/number}","milestones_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/milestones{/number}","notifications_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/labels{/name}","releases_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/releases{/id}","deployments_url":"https://api.github.com/repos/jlogeart/algoliasearch-client-scala/deployments","created_at":"2017-07-21T21:56:00Z","updated_at":"2017-07-21T21:56:01Z","pushed_at":"2017-08-02T14:35:56Z","git_url":"git://github.com/jlogeart/algoliasearch-client-scala.git","ssh_url":"git@github.com:jlogeart/algoliasearch-client-scala.git","clone_url":"https://github.com/jlogeart/algoliasearch-client-scala.git","svn_url":"https://github.com/jlogeart/algoliasearch-client-scala","homepage":"","size":688,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"algolia:master","ref":"master","sha":"12f321ca0977704eadf8777ab2bacb897bf196a4","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars0.githubusercontent.com/u/2034458?v=4","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":46281582,"name":"algoliasearch-client-scala","full_name":"algolia/algoliasearch-client-scala","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars0.githubusercontent.com/u/2034458?v=4","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/algoliasearch-client-scala","description":"Algolia Search API Client for Scala 2.11 & 2.12","fork":false,"url":"https://api.github.com/repos/algolia/algoliasearch-client-scala","forks_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/forks","keys_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/teams","hooks_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/hooks","issue_events_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/events","assignees_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/tags","blobs_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/languages","stargazers_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/stargazers","contributors_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/contributors","subscribers_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/subscribers","subscription_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/subscription","commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/merges","archive_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/downloads","issues_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/labels{/name}","releases_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/releases{/id}","deployments_url":"https://api.github.com/repos/algolia/algoliasearch-client-scala/deployments","created_at":"2015-11-16T14:57:49Z","updated_at":"2017-07-31T14:20:28Z","pushed_at":"2017-08-02T14:35:57Z","git_url":"git://github.com/algolia/algoliasearch-client-scala.git","ssh_url":"git@github.com:algolia/algoliasearch-client-scala.git","clone_url":"https://github.com/algolia/algoliasearch-client-scala.git","svn_url":"https://github.com/algolia/algoliasearch-client-scala","homepage":"","size":681,"stargazers_count":6,"watchers_count":6,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":5,"forks":11,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393"},"html":{"href":"https://github.com/algolia/algoliasearch-client-scala/pull/393"},"issue":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/393"},"comments":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/issues/393/comments"},"review_comments":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393/comments"},"review_comment":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/pulls/393/commits"},"statuses":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-scala/statuses/56299258c124101e0bb90669a1f801ca53d8f701"}}}}
{"actor":{"display_login":"ElPicador"}}