{"action":"created","issue":{"url":"https://api.github.com/repos/segmentio/analytics-go/issues/49","repository_url":"https://api.github.com/repos/segmentio/analytics-go","labels_url":"https://api.github.com/repos/segmentio/analytics-go/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/segmentio/analytics-go/issues/49/comments","events_url":"https://api.github.com/repos/segmentio/analytics-go/issues/49/events","html_url":"https://github.com/segmentio/analytics-go/pull/49","id":149082724,"number":49,"title":"Introduce ratelimiter using tokenbucket","user":{"login":"paddie","id":427074,"avatar_url":"https://avatars.githubusercontent.com/u/427074?v=3","gravatar_id":"","url":"https://api.github.com/users/paddie","html_url":"https://github.com/paddie","followers_url":"https://api.github.com/users/paddie/followers","following_url":"https://api.github.com/users/paddie/following{/other_user}","gists_url":"https://api.github.com/users/paddie/gists{/gist_id}","starred_url":"https://api.github.com/users/paddie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paddie/subscriptions","organizations_url":"https://api.github.com/users/paddie/orgs","repos_url":"https://api.github.com/users/paddie/repos","events_url":"https://api.github.com/users/paddie/events{/privacy}","received_events_url":"https://api.github.com/users/paddie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-18T08:39:35Z","updated_at":"2016-04-20T20:25:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics-go/pulls/49","html_url":"https://github.com/segmentio/analytics-go/pull/49","diff_url":"https://github.com/segmentio/analytics-go/pull/49.diff","patch_url":"https://github.com/segmentio/analytics-go/pull/49.patch"},"body":"Introduce ratelimiting of requests to a default (and configurable) rate of 50 per second using the tokenbucket implementation from Canonical's juju.\r\n\r\n__NOTE__\r\nI'm basing this PR on the #48 pull-request, and I'll make sure to keep them in sync pending code review etc. So, this should not be merged just yet or at all. Discuss."},"comment":{"url":"https://api.github.com/repos/segmentio/analytics-go/issues/comments/212588809","html_url":"https://github.com/segmentio/analytics-go/pull/49#issuecomment-212588809","issue_url":"https://api.github.com/repos/segmentio/analytics-go/issues/49","id":212588809,"user":{"login":"f2prateek","id":843979,"avatar_url":"https://avatars.githubusercontent.com/u/843979?v=3","gravatar_id":"","url":"https://api.github.com/users/f2prateek","html_url":"https://github.com/f2prateek","followers_url":"https://api.github.com/users/f2prateek/followers","following_url":"https://api.github.com/users/f2prateek/following{/other_user}","gists_url":"https://api.github.com/users/f2prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/f2prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2prateek/subscriptions","organizations_url":"https://api.github.com/users/f2prateek/orgs","repos_url":"https://api.github.com/users/f2prateek/repos","events_url":"https://api.github.com/users/f2prateek/events{/privacy}","received_events_url":"https://api.github.com/users/f2prateek/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T20:25:10Z","updated_at":"2016-04-20T20:25:10Z","body":"Yes, something like.\r\n\r\n```go\r\nlimiter := time.NewTicker(time.Second/50) // 50rps\r\n\r\n// https://github.com/segmentio/analytics-go/blob/master/analytics.go#L271\r\n<-limiter.C\r\nreq, err := http.NewRequest(\"POST\", url, bytes.NewReader(b))\r\n```"}}