{"action":"created","comment":{"url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/comments/76878496","id":76878496,"diff_hunk":"@@ -0,0 +1,54 @@\n+// Licensed under the Apache License, Version 2.0\n+// Details: https://raw.githubusercontent.com/maniksurtani/quotaservice/master/LICENSE\n+\n+package stats\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/maniksurtani/quotaservice/events\"\n+)\n+\n+type Listener interface {\n+\tTopHits(string) []*BucketScore\n+\tTopMisses(string) []*BucketScore\n+\tGet(string, string) *BucketScores\n+\tHandleEvent(events.Event)\n+}\n+\n+type BucketScores struct {\n+\tHits   int64 `json:\"hits\"`\n+\tMisses int64 `json:\"misses\"`\n+}\n+\n+type BucketScore struct {\n+\tBucket string `json:\"bucket\"`\n+\tScore  int64  `json:\"value\"`\n+}\n+\n+var emptyArr []*BucketScore\n+var emptyBucketScores *BucketScores\n+\n+func init() {\n+\temptyArr = make([]*BucketScore, 0)\n+\temptyBucketScores = &BucketScores{0, 0}\n+}\n+\n+func (b *BucketScore) String() string {\n+\treturn fmt.Sprintf(\"{%s, %d}\", b.Bucket, b.Score)\n+}\n+\n+// Implements a sortable BucketScore array\n+type BucketScoreArray []*BucketScore\n+\n+func (b BucketScoreArray) Len() int {","path":"stats/stats.go","position":44,"original_position":44,"commit_id":"e0f4142877a4c1dd8b47c24b15d3af6e80f12cd9","original_commit_id":"e0f4142877a4c1dd8b47c24b15d3af6e80f12cd9","user":{"login":"maniksurtani","id":47146,"avatar_url":"https://avatars.githubusercontent.com/u/47146?v=3","gravatar_id":"","url":"https://api.github.com/users/maniksurtani","html_url":"https://github.com/maniksurtani","followers_url":"https://api.github.com/users/maniksurtani/followers","following_url":"https://api.github.com/users/maniksurtani/following{/other_user}","gists_url":"https://api.github.com/users/maniksurtani/gists{/gist_id}","starred_url":"https://api.github.com/users/maniksurtani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniksurtani/subscriptions","organizations_url":"https://api.github.com/users/maniksurtani/orgs","repos_url":"https://api.github.com/users/maniksurtani/repos","events_url":"https://api.github.com/users/maniksurtani/events{/privacy}","received_events_url":"https://api.github.com/users/maniksurtani/received_events","type":"User","site_admin":false},"body":"Should these functions be on a `*BucketScoreArray` instead of a `BucketScoreArray`, to prevent a copy?","created_at":"2016-08-30T21:03:04Z","updated_at":"2016-08-30T21:03:04Z","html_url":"https://github.com/maniksurtani/quotaservice/pull/26#discussion_r76878496","pull_request_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/comments/76878496"},"html":{"href":"https://github.com/maniksurtani/quotaservice/pull/26#discussion_r76878496"},"pull_request":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26","id":83336522,"html_url":"https://github.com/maniksurtani/quotaservice/pull/26","diff_url":"https://github.com/maniksurtani/quotaservice/pull/26.diff","patch_url":"https://github.com/maniksurtani/quotaservice/pull/26.patch","issue_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/26","number":26,"state":"open","locked":false,"title":"add dynamic bucket stats listeners","user":{"login":"steved","id":13248,"avatar_url":"https://avatars.githubusercontent.com/u/13248?v=3","gravatar_id":"","url":"https://api.github.com/users/steved","html_url":"https://github.com/steved","followers_url":"https://api.github.com/users/steved/followers","following_url":"https://api.github.com/users/steved/following{/other_user}","gists_url":"https://api.github.com/users/steved/gists{/gist_id}","starred_url":"https://api.github.com/users/steved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steved/subscriptions","organizations_url":"https://api.github.com/users/steved/orgs","repos_url":"https://api.github.com/users/steved/repos","events_url":"https://api.github.com/users/steved/events{/privacy}","received_events_url":"https://api.github.com/users/steved/received_events","type":"User","site_admin":false},"body":"Redis stats are clamped to the hour, I kept the memory ones unbounded.\r\nMisses are just total hits, but can be changed to a ratio if that's more helpful.\r\n\r\n@maniksurtani ","created_at":"2016-08-30T19:58:15Z","updated_at":"2016-08-30T21:03:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"80f10a5087038f3e4cb4b13ba1b946f3363084c7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26/commits","review_comments_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26/comments","review_comment_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/26/comments","statuses_url":"https://api.github.com/repos/maniksurtani/quotaservice/statuses/e0f4142877a4c1dd8b47c24b15d3af6e80f12cd9","head":{"label":"maniksurtani:steved/stats","ref":"steved/stats","sha":"e0f4142877a4c1dd8b47c24b15d3af6e80f12cd9","user":{"login":"maniksurtani","id":47146,"avatar_url":"https://avatars.githubusercontent.com/u/47146?v=3","gravatar_id":"","url":"https://api.github.com/users/maniksurtani","html_url":"https://github.com/maniksurtani","followers_url":"https://api.github.com/users/maniksurtani/followers","following_url":"https://api.github.com/users/maniksurtani/following{/other_user}","gists_url":"https://api.github.com/users/maniksurtani/gists{/gist_id}","starred_url":"https://api.github.com/users/maniksurtani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniksurtani/subscriptions","organizations_url":"https://api.github.com/users/maniksurtani/orgs","repos_url":"https://api.github.com/users/maniksurtani/repos","events_url":"https://api.github.com/users/maniksurtani/events{/privacy}","received_events_url":"https://api.github.com/users/maniksurtani/received_events","type":"User","site_admin":false},"repo":{"id":46589610,"name":"quotaservice","full_name":"maniksurtani/quotaservice","owner":{"login":"maniksurtani","id":47146,"avatar_url":"https://avatars.githubusercontent.com/u/47146?v=3","gravatar_id":"","url":"https://api.github.com/users/maniksurtani","html_url":"https://github.com/maniksurtani","followers_url":"https://api.github.com/users/maniksurtani/followers","following_url":"https://api.github.com/users/maniksurtani/following{/other_user}","gists_url":"https://api.github.com/users/maniksurtani/gists{/gist_id}","starred_url":"https://api.github.com/users/maniksurtani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniksurtani/subscriptions","organizations_url":"https://api.github.com/users/maniksurtani/orgs","repos_url":"https://api.github.com/users/maniksurtani/repos","events_url":"https://api.github.com/users/maniksurtani/events{/privacy}","received_events_url":"https://api.github.com/users/maniksurtani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maniksurtani/quotaservice","description":"The purpose of a quota service is to prevent cascading failures in micro-service environments. The service acts as a traffic cop, slowing down traffic where necessary to prevent overloading services. For this to work, remote procedure calls (RPCs) between services consult the quota service before making a call. The service isn’t strictly for RPCs between services, and can even be used to apply quotas to database calls, for example.","fork":false,"url":"https://api.github.com/repos/maniksurtani/quotaservice","forks_url":"https://api.github.com/repos/maniksurtani/quotaservice/forks","keys_url":"https://api.github.com/repos/maniksurtani/quotaservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maniksurtani/quotaservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maniksurtani/quotaservice/teams","hooks_url":"https://api.github.com/repos/maniksurtani/quotaservice/hooks","issue_events_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/events{/number}","events_url":"https://api.github.com/repos/maniksurtani/quotaservice/events","assignees_url":"https://api.github.com/repos/maniksurtani/quotaservice/assignees{/user}","branches_url":"https://api.github.com/repos/maniksurtani/quotaservice/branches{/branch}","tags_url":"https://api.github.com/repos/maniksurtani/quotaservice/tags","blobs_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maniksurtani/quotaservice/statuses/{sha}","languages_url":"https://api.github.com/repos/maniksurtani/quotaservice/languages","stargazers_url":"https://api.github.com/repos/maniksurtani/quotaservice/stargazers","contributors_url":"https://api.github.com/repos/maniksurtani/quotaservice/contributors","subscribers_url":"https://api.github.com/repos/maniksurtani/quotaservice/subscribers","subscription_url":"https://api.github.com/repos/maniksurtani/quotaservice/subscription","commits_url":"https://api.github.com/repos/maniksurtani/quotaservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/maniksurtani/quotaservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/maniksurtani/quotaservice/contents/{+path}","compare_url":"https://api.github.com/repos/maniksurtani/quotaservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maniksurtani/quotaservice/merges","archive_url":"https://api.github.com/repos/maniksurtani/quotaservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maniksurtani/quotaservice/downloads","issues_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues{/number}","pulls_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls{/number}","milestones_url":"https://api.github.com/repos/maniksurtani/quotaservice/milestones{/number}","notifications_url":"https://api.github.com/repos/maniksurtani/quotaservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maniksurtani/quotaservice/labels{/name}","releases_url":"https://api.github.com/repos/maniksurtani/quotaservice/releases{/id}","deployments_url":"https://api.github.com/repos/maniksurtani/quotaservice/deployments","created_at":"2015-11-20T22:11:12Z","updated_at":"2016-04-28T21:49:21Z","pushed_at":"2016-08-30T19:58:15Z","git_url":"git://github.com/maniksurtani/quotaservice.git","ssh_url":"git@github.com:maniksurtani/quotaservice.git","clone_url":"https://github.com/maniksurtani/quotaservice.git","svn_url":"https://github.com/maniksurtani/quotaservice","homepage":"","size":4113,"stargazers_count":4,"watchers_count":4,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"base":{"label":"maniksurtani:master","ref":"master","sha":"62e4de9eb8a869a9a33f90bdaa1183b82c5c6f79","user":{"login":"maniksurtani","id":47146,"avatar_url":"https://avatars.githubusercontent.com/u/47146?v=3","gravatar_id":"","url":"https://api.github.com/users/maniksurtani","html_url":"https://github.com/maniksurtani","followers_url":"https://api.github.com/users/maniksurtani/followers","following_url":"https://api.github.com/users/maniksurtani/following{/other_user}","gists_url":"https://api.github.com/users/maniksurtani/gists{/gist_id}","starred_url":"https://api.github.com/users/maniksurtani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniksurtani/subscriptions","organizations_url":"https://api.github.com/users/maniksurtani/orgs","repos_url":"https://api.github.com/users/maniksurtani/repos","events_url":"https://api.github.com/users/maniksurtani/events{/privacy}","received_events_url":"https://api.github.com/users/maniksurtani/received_events","type":"User","site_admin":false},"repo":{"id":46589610,"name":"quotaservice","full_name":"maniksurtani/quotaservice","owner":{"login":"maniksurtani","id":47146,"avatar_url":"https://avatars.githubusercontent.com/u/47146?v=3","gravatar_id":"","url":"https://api.github.com/users/maniksurtani","html_url":"https://github.com/maniksurtani","followers_url":"https://api.github.com/users/maniksurtani/followers","following_url":"https://api.github.com/users/maniksurtani/following{/other_user}","gists_url":"https://api.github.com/users/maniksurtani/gists{/gist_id}","starred_url":"https://api.github.com/users/maniksurtani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maniksurtani/subscriptions","organizations_url":"https://api.github.com/users/maniksurtani/orgs","repos_url":"https://api.github.com/users/maniksurtani/repos","events_url":"https://api.github.com/users/maniksurtani/events{/privacy}","received_events_url":"https://api.github.com/users/maniksurtani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maniksurtani/quotaservice","description":"The purpose of a quota service is to prevent cascading failures in micro-service environments. The service acts as a traffic cop, slowing down traffic where necessary to prevent overloading services. For this to work, remote procedure calls (RPCs) between services consult the quota service before making a call. The service isn’t strictly for RPCs between services, and can even be used to apply quotas to database calls, for example.","fork":false,"url":"https://api.github.com/repos/maniksurtani/quotaservice","forks_url":"https://api.github.com/repos/maniksurtani/quotaservice/forks","keys_url":"https://api.github.com/repos/maniksurtani/quotaservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maniksurtani/quotaservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maniksurtani/quotaservice/teams","hooks_url":"https://api.github.com/repos/maniksurtani/quotaservice/hooks","issue_events_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/events{/number}","events_url":"https://api.github.com/repos/maniksurtani/quotaservice/events","assignees_url":"https://api.github.com/repos/maniksurtani/quotaservice/assignees{/user}","branches_url":"https://api.github.com/repos/maniksurtani/quotaservice/branches{/branch}","tags_url":"https://api.github.com/repos/maniksurtani/quotaservice/tags","blobs_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maniksurtani/quotaservice/statuses/{sha}","languages_url":"https://api.github.com/repos/maniksurtani/quotaservice/languages","stargazers_url":"https://api.github.com/repos/maniksurtani/quotaservice/stargazers","contributors_url":"https://api.github.com/repos/maniksurtani/quotaservice/contributors","subscribers_url":"https://api.github.com/repos/maniksurtani/quotaservice/subscribers","subscription_url":"https://api.github.com/repos/maniksurtani/quotaservice/subscription","commits_url":"https://api.github.com/repos/maniksurtani/quotaservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/maniksurtani/quotaservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/maniksurtani/quotaservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/maniksurtani/quotaservice/contents/{+path}","compare_url":"https://api.github.com/repos/maniksurtani/quotaservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maniksurtani/quotaservice/merges","archive_url":"https://api.github.com/repos/maniksurtani/quotaservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maniksurtani/quotaservice/downloads","issues_url":"https://api.github.com/repos/maniksurtani/quotaservice/issues{/number}","pulls_url":"https://api.github.com/repos/maniksurtani/quotaservice/pulls{/number}","milestones_url":"https://api.github.com/repos/maniksurtani/quotaservice/milestones{/number}","notifications_url":"https://api.github.com/repos/maniksurtani/quotaservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maniksurtani/quotaservice/labels{/name}","releases_url":"https://api.github.com/repos/maniksurtani/quotaservice/releases{/id}","deployments_url":"https://api.github.com/repos/maniksurtani/quotaservice/deployments","created_at":"2015-11-20T22:11:12Z","updated_at":"2016-04-28T21:49:21Z","pushed_at":"2016-08-30T19:58:15Z","git_url":"git://github.com/maniksurtani/quotaservice.git","ssh_url":"git@github.com:maniksurtani/quotaservice.git","clone_url":"https://github.com/maniksurtani/quotaservice.git","svn_url":"https://github.com/maniksurtani/quotaservice","homepage":"","size":4113,"stargazers_count":4,"watchers_count":4,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26"},"html":{"href":"https://github.com/maniksurtani/quotaservice/pull/26"},"issue":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/issues/26"},"comments":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/maniksurtani/quotaservice/statuses/e0f4142877a4c1dd8b47c24b15d3af6e80f12cd9"}}}}
{"actor":{"display_login":"maniksurtani"}}