{"action":"created","comment":{"url":"https://api.github.com/repos/forter/georg/pulls/comments/37837281","id":37837281,"diff_hunk":"@@ -15,40 +15,68 @@\n  *******************************************************************************/\n \n var riemann = require('riemann');\n-var settings = { initialReconnectTimeoutMS: 1000, //The initial time-gap for the reconnectTimeout\n-                 reconnectLimitMS : 10000,        //The max limit for the reconnectTimeout\n-                 keepAliveIntervalMS : 60000};     //The time-gap between each keepAlive message sending\n+var settings = {\n+    maxRetryDelayMS: 10000,          //The maximum retry time between attempts of reconnect\n+    initialReconnectTimeoutMS: 1000, //The initial time-gap for the reconnectTimeout\n+    reconnectLimitMS : 10000,        //The max limit for the reconnectTimeout\n+    keepAliveIntervalMS : 60000,     //The time-gap between each keepAlive message sending\n+    reconnectMaximumRetries: -1      //The maxmimum reconnect retries, default -1 which means no limit\n+};\n \n-var keepAlive, reconnectTimeoutMS = settings.initialReconnectTimeoutMS;\n+var keepAlive, reconnectTimeoutMS = settings.initialReconnectTimeoutMS, reconnectRetry = 0;\n var riemannClient = {};\n var _ = require('underscore');\n var utils = require('./utils');\n+var logger = require('./logger');\n \n var ipAddress = require('ip').address();\n+var retryConnecting = 0;\n+\n+function isReconnectMaximumRetriesDisabled(reconnectMaximumRetries) {\n+    return reconnectMaximumRetries === -1;\n+}\n+\n+function getReconnectTimeoutMS(reconnectTimeoutMS, reconnectRetry, maxRetryDelayMS) {\n+    if (reconnectRetry === 1) {\n+        return 0;\n+    }\n+    // Riemann was not started yet. Reconnect using better exponential backoff\n+    // Random ms for distributed riemann client\n+    var newReconnectTimeoutMS = Math.round(Math.random()*500) * Math.pow(2,reconnectRetry);","path":"lib/riemannConnection.js","position":35,"original_position":35,"commit_id":"ff0f91639405b92232b0e71ce7baa0c615cb13d0","original_commit_id":"ff0f91639405b92232b0e71ce7baa0c615cb13d0","user":{"login":"itaifrenkel","id":387337,"avatar_url":"https://avatars.githubusercontent.com/u/387337?v=3","gravatar_id":"","url":"https://api.github.com/users/itaifrenkel","html_url":"https://github.com/itaifrenkel","followers_url":"https://api.github.com/users/itaifrenkel/followers","following_url":"https://api.github.com/users/itaifrenkel/following{/other_user}","gists_url":"https://api.github.com/users/itaifrenkel/gists{/gist_id}","starred_url":"https://api.github.com/users/itaifrenkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itaifrenkel/subscriptions","organizations_url":"https://api.github.com/users/itaifrenkel/orgs","repos_url":"https://api.github.com/users/itaifrenkel/repos","events_url":"https://api.github.com/users/itaifrenkel/events{/privacy}","received_events_url":"https://api.github.com/users/itaifrenkel/received_events","type":"User","site_admin":false},"body":"delay1 = Math.random()*100 + 400\r\n...\r\n...\r\nvar nextDelay = delay1 * Math.pow(2,reconnectRetry);","created_at":"2015-08-25T06:50:10Z","updated_at":"2015-08-25T06:50:10Z","html_url":"https://github.com/forter/georg/pull/36#discussion_r37837281","pull_request_url":"https://api.github.com/repos/forter/georg/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/forter/georg/pulls/comments/37837281"},"html":{"href":"https://github.com/forter/georg/pull/36#discussion_r37837281"},"pull_request":{"href":"https://api.github.com/repos/forter/georg/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/forter/georg/pulls/36","id":42892780,"html_url":"https://github.com/forter/georg/pull/36","diff_url":"https://github.com/forter/georg/pull/36.diff","patch_url":"https://github.com/forter/georg/pull/36.patch","issue_url":"https://api.github.com/repos/forter/georg/issues/36","number":36,"state":"open","locked":false,"title":"adding reconnect maximum retries","user":{"login":"lgoldenberg","id":6441473,"avatar_url":"https://avatars.githubusercontent.com/u/6441473?v=3","gravatar_id":"","url":"https://api.github.com/users/lgoldenberg","html_url":"https://github.com/lgoldenberg","followers_url":"https://api.github.com/users/lgoldenberg/followers","following_url":"https://api.github.com/users/lgoldenberg/following{/other_user}","gists_url":"https://api.github.com/users/lgoldenberg/gists{/gist_id}","starred_url":"https://api.github.com/users/lgoldenberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgoldenberg/subscriptions","organizations_url":"https://api.github.com/users/lgoldenberg/orgs","repos_url":"https://api.github.com/users/lgoldenberg/repos","events_url":"https://api.github.com/users/lgoldenberg/events{/privacy}","received_events_url":"https://api.github.com/users/lgoldenberg/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-20T05:26:32Z","updated_at":"2015-08-25T06:50:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87488dc32f0b595b5de3ec7b0e86e04e64657fa2","assignee":{"login":"MosheZada","id":7490448,"avatar_url":"https://avatars.githubusercontent.com/u/7490448?v=3","gravatar_id":"","url":"https://api.github.com/users/MosheZada","html_url":"https://github.com/MosheZada","followers_url":"https://api.github.com/users/MosheZada/followers","following_url":"https://api.github.com/users/MosheZada/following{/other_user}","gists_url":"https://api.github.com/users/MosheZada/gists{/gist_id}","starred_url":"https://api.github.com/users/MosheZada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MosheZada/subscriptions","organizations_url":"https://api.github.com/users/MosheZada/orgs","repos_url":"https://api.github.com/users/MosheZada/repos","events_url":"https://api.github.com/users/MosheZada/events{/privacy}","received_events_url":"https://api.github.com/users/MosheZada/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/forter/georg/pulls/36/commits","review_comments_url":"https://api.github.com/repos/forter/georg/pulls/36/comments","review_comment_url":"https://api.github.com/repos/forter/georg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/forter/georg/issues/36/comments","statuses_url":"https://api.github.com/repos/forter/georg/statuses/ff0f91639405b92232b0e71ce7baa0c615cb13d0","head":{"label":"forter:lirong-riemann-add-reconnect-retries-limit-feature","ref":"lirong-riemann-add-reconnect-retries-limit-feature","sha":"ff0f91639405b92232b0e71ce7baa0c615cb13d0","user":{"login":"forter","id":6420463,"avatar_url":"https://avatars.githubusercontent.com/u/6420463?v=3","gravatar_id":"","url":"https://api.github.com/users/forter","html_url":"https://github.com/forter","followers_url":"https://api.github.com/users/forter/followers","following_url":"https://api.github.com/users/forter/following{/other_user}","gists_url":"https://api.github.com/users/forter/gists{/gist_id}","starred_url":"https://api.github.com/users/forter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forter/subscriptions","organizations_url":"https://api.github.com/users/forter/orgs","repos_url":"https://api.github.com/users/forter/repos","events_url":"https://api.github.com/users/forter/events{/privacy}","received_events_url":"https://api.github.com/users/forter/received_events","type":"Organization","site_admin":false},"repo":{"id":19831128,"name":"georg","full_name":"forter/georg","owner":{"login":"forter","id":6420463,"avatar_url":"https://avatars.githubusercontent.com/u/6420463?v=3","gravatar_id":"","url":"https://api.github.com/users/forter","html_url":"https://github.com/forter","followers_url":"https://api.github.com/users/forter/followers","following_url":"https://api.github.com/users/forter/following{/other_user}","gists_url":"https://api.github.com/users/forter/gists{/gist_id}","starred_url":"https://api.github.com/users/forter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forter/subscriptions","organizations_url":"https://api.github.com/users/forter/orgs","repos_url":"https://api.github.com/users/forter/repos","events_url":"https://api.github.com/users/forter/events{/privacy}","received_events_url":"https://api.github.com/users/forter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/forter/georg","description":"Georg","fork":false,"url":"https://api.github.com/repos/forter/georg","forks_url":"https://api.github.com/repos/forter/georg/forks","keys_url":"https://api.github.com/repos/forter/georg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/forter/georg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/forter/georg/teams","hooks_url":"https://api.github.com/repos/forter/georg/hooks","issue_events_url":"https://api.github.com/repos/forter/georg/issues/events{/number}","events_url":"https://api.github.com/repos/forter/georg/events","assignees_url":"https://api.github.com/repos/forter/georg/assignees{/user}","branches_url":"https://api.github.com/repos/forter/georg/branches{/branch}","tags_url":"https://api.github.com/repos/forter/georg/tags","blobs_url":"https://api.github.com/repos/forter/georg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/forter/georg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/forter/georg/git/refs{/sha}","trees_url":"https://api.github.com/repos/forter/georg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/forter/georg/statuses/{sha}","languages_url":"https://api.github.com/repos/forter/georg/languages","stargazers_url":"https://api.github.com/repos/forter/georg/stargazers","contributors_url":"https://api.github.com/repos/forter/georg/contributors","subscribers_url":"https://api.github.com/repos/forter/georg/subscribers","subscription_url":"https://api.github.com/repos/forter/georg/subscription","commits_url":"https://api.github.com/repos/forter/georg/commits{/sha}","git_commits_url":"https://api.github.com/repos/forter/georg/git/commits{/sha}","comments_url":"https://api.github.com/repos/forter/georg/comments{/number}","issue_comment_url":"https://api.github.com/repos/forter/georg/issues/comments{/number}","contents_url":"https://api.github.com/repos/forter/georg/contents/{+path}","compare_url":"https://api.github.com/repos/forter/georg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/forter/georg/merges","archive_url":"https://api.github.com/repos/forter/georg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/forter/georg/downloads","issues_url":"https://api.github.com/repos/forter/georg/issues{/number}","pulls_url":"https://api.github.com/repos/forter/georg/pulls{/number}","milestones_url":"https://api.github.com/repos/forter/georg/milestones{/number}","notifications_url":"https://api.github.com/repos/forter/georg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/forter/georg/labels{/name}","releases_url":"https://api.github.com/repos/forter/georg/releases{/id}","created_at":"2014-05-15T18:45:50Z","updated_at":"2015-08-19T08:47:22Z","pushed_at":"2015-08-24T11:55:56Z","git_url":"git://github.com/forter/georg.git","ssh_url":"git@github.com:forter/georg.git","clone_url":"https://github.com/forter/georg.git","svn_url":"https://github.com/forter/georg","homepage":null,"size":961,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"forter:master","ref":"master","sha":"d2ca95a4e830f3130b1428be85e91da008254263","user":{"login":"forter","id":6420463,"avatar_url":"https://avatars.githubusercontent.com/u/6420463?v=3","gravatar_id":"","url":"https://api.github.com/users/forter","html_url":"https://github.com/forter","followers_url":"https://api.github.com/users/forter/followers","following_url":"https://api.github.com/users/forter/following{/other_user}","gists_url":"https://api.github.com/users/forter/gists{/gist_id}","starred_url":"https://api.github.com/users/forter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forter/subscriptions","organizations_url":"https://api.github.com/users/forter/orgs","repos_url":"https://api.github.com/users/forter/repos","events_url":"https://api.github.com/users/forter/events{/privacy}","received_events_url":"https://api.github.com/users/forter/received_events","type":"Organization","site_admin":false},"repo":{"id":19831128,"name":"georg","full_name":"forter/georg","owner":{"login":"forter","id":6420463,"avatar_url":"https://avatars.githubusercontent.com/u/6420463?v=3","gravatar_id":"","url":"https://api.github.com/users/forter","html_url":"https://github.com/forter","followers_url":"https://api.github.com/users/forter/followers","following_url":"https://api.github.com/users/forter/following{/other_user}","gists_url":"https://api.github.com/users/forter/gists{/gist_id}","starred_url":"https://api.github.com/users/forter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forter/subscriptions","organizations_url":"https://api.github.com/users/forter/orgs","repos_url":"https://api.github.com/users/forter/repos","events_url":"https://api.github.com/users/forter/events{/privacy}","received_events_url":"https://api.github.com/users/forter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/forter/georg","description":"Georg","fork":false,"url":"https://api.github.com/repos/forter/georg","forks_url":"https://api.github.com/repos/forter/georg/forks","keys_url":"https://api.github.com/repos/forter/georg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/forter/georg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/forter/georg/teams","hooks_url":"https://api.github.com/repos/forter/georg/hooks","issue_events_url":"https://api.github.com/repos/forter/georg/issues/events{/number}","events_url":"https://api.github.com/repos/forter/georg/events","assignees_url":"https://api.github.com/repos/forter/georg/assignees{/user}","branches_url":"https://api.github.com/repos/forter/georg/branches{/branch}","tags_url":"https://api.github.com/repos/forter/georg/tags","blobs_url":"https://api.github.com/repos/forter/georg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/forter/georg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/forter/georg/git/refs{/sha}","trees_url":"https://api.github.com/repos/forter/georg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/forter/georg/statuses/{sha}","languages_url":"https://api.github.com/repos/forter/georg/languages","stargazers_url":"https://api.github.com/repos/forter/georg/stargazers","contributors_url":"https://api.github.com/repos/forter/georg/contributors","subscribers_url":"https://api.github.com/repos/forter/georg/subscribers","subscription_url":"https://api.github.com/repos/forter/georg/subscription","commits_url":"https://api.github.com/repos/forter/georg/commits{/sha}","git_commits_url":"https://api.github.com/repos/forter/georg/git/commits{/sha}","comments_url":"https://api.github.com/repos/forter/georg/comments{/number}","issue_comment_url":"https://api.github.com/repos/forter/georg/issues/comments{/number}","contents_url":"https://api.github.com/repos/forter/georg/contents/{+path}","compare_url":"https://api.github.com/repos/forter/georg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/forter/georg/merges","archive_url":"https://api.github.com/repos/forter/georg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/forter/georg/downloads","issues_url":"https://api.github.com/repos/forter/georg/issues{/number}","pulls_url":"https://api.github.com/repos/forter/georg/pulls{/number}","milestones_url":"https://api.github.com/repos/forter/georg/milestones{/number}","notifications_url":"https://api.github.com/repos/forter/georg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/forter/georg/labels{/name}","releases_url":"https://api.github.com/repos/forter/georg/releases{/id}","created_at":"2014-05-15T18:45:50Z","updated_at":"2015-08-19T08:47:22Z","pushed_at":"2015-08-24T11:55:56Z","git_url":"git://github.com/forter/georg.git","ssh_url":"git@github.com:forter/georg.git","clone_url":"https://github.com/forter/georg.git","svn_url":"https://github.com/forter/georg","homepage":null,"size":961,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/forter/georg/pulls/36"},"html":{"href":"https://github.com/forter/georg/pull/36"},"issue":{"href":"https://api.github.com/repos/forter/georg/issues/36"},"comments":{"href":"https://api.github.com/repos/forter/georg/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/forter/georg/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/forter/georg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/forter/georg/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/forter/georg/statuses/ff0f91639405b92232b0e71ce7baa0c615cb13d0"}}}}