{"action":"opened","issue":{"url":"https://api.github.com/repos/Tolerance/Tolerance/issues/102","repository_url":"https://api.github.com/repos/Tolerance/Tolerance","labels_url":"https://api.github.com/repos/Tolerance/Tolerance/issues/102/labels{/name}","comments_url":"https://api.github.com/repos/Tolerance/Tolerance/issues/102/comments","events_url":"https://api.github.com/repos/Tolerance/Tolerance/issues/102/events","html_url":"https://github.com/Tolerance/Tolerance/issues/102","id":272988090,"number":102,"title":"Add a random factor parameter to ExponentialBackOff","user":{"login":"shouze","id":54712,"avatar_url":"https://avatars0.githubusercontent.com/u/54712?v=4","gravatar_id":"","url":"https://api.github.com/users/shouze","html_url":"https://github.com/shouze","followers_url":"https://api.github.com/users/shouze/followers","following_url":"https://api.github.com/users/shouze/following{/other_user}","gists_url":"https://api.github.com/users/shouze/gists{/gist_id}","starred_url":"https://api.github.com/users/shouze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shouze/subscriptions","organizations_url":"https://api.github.com/users/shouze/orgs","repos_url":"https://api.github.com/users/shouze/repos","events_url":"https://api.github.com/users/shouze/events{/privacy}","received_events_url":"https://api.github.com/users/shouze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-10T16:29:39Z","updated_at":"2017-11-10T16:29:39Z","closed_at":null,"author_association":"NONE","body":"Currently the ExponentialBackOff constructor is the following:\r\nhttps://github.com/Tolerance/Tolerance/blob/6242d431ce980d4f273e890f77113f1b39cef9a8/src/Tolerance/Waiter/ExponentialBackOff.php#L41\r\n\r\nI suggest adding a new parameter `drift` at the end with a default value of `0.0`:\r\n```php\r\npublic function __construct(Waiter $waiter, $initialExponent, $step = 1.0, $stepRandomFactor = 0.0)\r\n```\r\n\r\n## What is this value?\r\n\r\nThe goal is to add some randomness to the waiter next value. This is useful for concurrent calls to avoid them to be too much massively synchronized.\r\n\r\n## How?\r\n\r\n`$stepRandomFactor` should be a value between `0.0` and `1.0` that will behave [like in this code for example](https://github.com/MathieuTurcotte/node-backoff/blob/811118fd1f89e9ca4e6b67292b9ef5da6c4f60e9/lib/strategy/strategy.js#L54-L61):\r\n```js\r\n// Template method that computes and returns the next backoff delay in\r\n// milliseconds.\r\nBackoffStrategy.prototype.next = function() {\r\n    var backoffDelay = this.next_();\r\n    var randomisationMultiple = 1 + Math.random() * this.randomisationFactor_;\r\n    var randomizedDelay = Math.round(backoffDelay * randomisationMultiple);\r\n    return randomizedDelay;\r\n};\r\n```\r\n\r\nMaybe it should even be more useful to have this argument moved directly into the waiter?"}}
{"actor":{"display_login":"shouze"}}