payload: {"action":"created","comment":{"url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/comments/286392625","pull_request_review_id":240506012,"id":286392625,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4NjM5MjYyNQ==","diff_hunk":"@@ -0,0 +1,63 @@\n+// See LICENSE for licensing terms.\n+\n+package ratelimit\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"golang.org/x/net/context\"\n+\t\"google.golang.org/grpc\"\n+\t\"google.golang.org/grpc/codes\"\n+\t\"google.golang.org/grpc/status\"\n+)\n+\n+type Limiter interface {\n+\tLimit() bool\n+}\n+\n+type rateLimiter struct {\n+\tlimiter Limiter\n+}\n+\n+type emptyLimiter struct{}\n+\n+func (e *emptyLimiter) Limit() bool {\n+\treturn false\n+}\n+\n+func emptyRatelimiter() *rateLimiter {\n+\treturn &rateLimiter{\n+\t\tlimiter: &emptyLimiter{},\n+\t}\n+}\n+\n+// UnaryServerInterceptor returns a new unary server interceptors that performs request rate limit.\n+func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {\n+\tratelimiter := emptyRatelimiter()\n+\tfor _, opt := range opts {\n+\t\topt(ratelimiter)\n+\t}\n+\treturn func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {\n+\t\tif ratelimiter.limiter.Limit() {\n+\t\t\treturn nil, status.Errorf(codes.ResourceExhausted, \"%s is rejected by grpc_ratelimit middleare, please retry later.\", info.FullMethod)\n+\t\t}\n+\t\treturn handler(ctx, req)\n+\t}\n+}\n+\n+// StreamServerInterceptor returns a new stream server interceptor that performs rate limiting on the request.\n+func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {\n+\tratelimiter := emptyRatelimiter()\n+\tfmt.Println(ratelimiter.limiter.Limit())\n+\tfor _, opt := range opts {\n+\t\topt(ratelimiter)\n+\t}\n+\tfmt.Println(ratelimiter.limiter.Limit())","path":"ratelimit/ratelimit.go","position":55,"original_position":55,"commit_id":"4b75c008f6218ea7e097a124e8b8e47502c64235","original_commit_id":"4b75c008f6218ea7e097a124e8b8e47502c64235","user":{"login":"domgreen","id":156558,"node_id":"MDQ6VXNlcjE1NjU1OA==","avatar_url":"https://avatars0.githubusercontent.com/u/156558?v=4","gravatar_id":"","url":"https://api.github.com/users/domgreen","html_url":"https://github.com/domgreen","followers_url":"https://api.github.com/users/domgreen/followers","following_url":"https://api.github.com/users/domgreen/following{/other_user}","gists_url":"https://api.github.com/users/domgreen/gists{/gist_id}","starred_url":"https://api.github.com/users/domgreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domgreen/subscriptions","organizations_url":"https://api.github.com/users/domgreen/orgs","repos_url":"https://api.github.com/users/domgreen/repos","events_url":"https://api.github.com/users/domgreen/events{/privacy}","received_events_url":"https://api.github.com/users/domgreen/received_events","type":"User","site_admin":false},"body":"remove Println","created_at":"2019-05-22T09:19:45Z","updated_at":"2019-05-22T09:25:59Z","html_url":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181#discussion_r286392625","pull_request_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/comments/286392625"},"html":{"href":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181#discussion_r286392625"},"pull_request":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181"}}},"pull_request":{"url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181","id":238271376,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4MjcxMzc2","html_url":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181","diff_url":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181.diff","patch_url":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181.patch","issue_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/181","number":181,"state":"open","locked":false,"title":"Ratelimit interceptor","user":{"login":"ceshihao","id":7711875,"node_id":"MDQ6VXNlcjc3MTE4NzU=","avatar_url":"https://avatars3.githubusercontent.com/u/7711875?v=4","gravatar_id":"","url":"https://api.github.com/users/ceshihao","html_url":"https://github.com/ceshihao","followers_url":"https://api.github.com/users/ceshihao/followers","following_url":"https://api.github.com/users/ceshihao/following{/other_user}","gists_url":"https://api.github.com/users/ceshihao/gists{/gist_id}","starred_url":"https://api.github.com/users/ceshihao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceshihao/subscriptions","organizations_url":"https://api.github.com/users/ceshihao/orgs","repos_url":"https://api.github.com/users/ceshihao/repos","events_url":"https://api.github.com/users/ceshihao/events{/privacy}","received_events_url":"https://api.github.com/users/ceshihao/received_events","type":"User","site_admin":false},"body":"Add ratelimit interceptor, and implement a token bucket limiter using `github.com/juju/ratelimit`\r\n\r\nFix #134","created_at":"2018-12-13T05:44:22Z","updated_at":"2019-05-22T09:25:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4be56bd328873dd7d43c25d5c0685199d63cc5fd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181/commits","review_comments_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181/comments","review_comment_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/181/comments","statuses_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/statuses/4b75c008f6218ea7e097a124e8b8e47502c64235","head":{"label":"ceshihao:ratelimit_interceptor","ref":"ratelimit_interceptor","sha":"4b75c008f6218ea7e097a124e8b8e47502c64235","user":{"login":"ceshihao","id":7711875,"node_id":"MDQ6VXNlcjc3MTE4NzU=","avatar_url":"https://avatars3.githubusercontent.com/u/7711875?v=4","gravatar_id":"","url":"https://api.github.com/users/ceshihao","html_url":"https://github.com/ceshihao","followers_url":"https://api.github.com/users/ceshihao/followers","following_url":"https://api.github.com/users/ceshihao/following{/other_user}","gists_url":"https://api.github.com/users/ceshihao/gists{/gist_id}","starred_url":"https://api.github.com/users/ceshihao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceshihao/subscriptions","organizations_url":"https://api.github.com/users/ceshihao/orgs","repos_url":"https://api.github.com/users/ceshihao/repos","events_url":"https://api.github.com/users/ceshihao/events{/privacy}","received_events_url":"https://api.github.com/users/ceshihao/received_events","type":"User","site_admin":false},"repo":{"id":160612803,"node_id":"MDEwOlJlcG9zaXRvcnkxNjA2MTI4MDM=","name":"go-grpc-middleware","full_name":"ceshihao/go-grpc-middleware","private":false,"owner":{"login":"ceshihao","id":7711875,"node_id":"MDQ6VXNlcjc3MTE4NzU=","avatar_url":"https://avatars3.githubusercontent.com/u/7711875?v=4","gravatar_id":"","url":"https://api.github.com/users/ceshihao","html_url":"https://github.com/ceshihao","followers_url":"https://api.github.com/users/ceshihao/followers","following_url":"https://api.github.com/users/ceshihao/following{/other_user}","gists_url":"https://api.github.com/users/ceshihao/gists{/gist_id}","starred_url":"https://api.github.com/users/ceshihao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceshihao/subscriptions","organizations_url":"https://api.github.com/users/ceshihao/orgs","repos_url":"https://api.github.com/users/ceshihao/repos","events_url":"https://api.github.com/users/ceshihao/events{/privacy}","received_events_url":"https://api.github.com/users/ceshihao/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ceshihao/go-grpc-middleware","description":"Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.","fork":true,"url":"https://api.github.com/repos/ceshihao/go-grpc-middleware","forks_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/forks","keys_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/teams","hooks_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/hooks","issue_events_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/issues/events{/number}","events_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/events","assignees_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/assignees{/user}","branches_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/branches{/branch}","tags_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/tags","blobs_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/statuses/{sha}","languages_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/languages","stargazers_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/stargazers","contributors_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/contributors","subscribers_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/subscribers","subscription_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/subscription","commits_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/contents/{+path}","compare_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/merges","archive_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/downloads","issues_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/issues{/number}","pulls_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/pulls{/number}","milestones_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/milestones{/number}","notifications_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/labels{/name}","releases_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/releases{/id}","deployments_url":"https://api.github.com/repos/ceshihao/go-grpc-middleware/deployments","created_at":"2018-12-06T03:22:38Z","updated_at":"2018-12-06T03:22:40Z","pushed_at":"2019-05-21T13:48:32Z","git_url":"git://github.com/ceshihao/go-grpc-middleware.git","ssh_url":"git@github.com:ceshihao/go-grpc-middleware.git","clone_url":"https://github.com/ceshihao/go-grpc-middleware.git","svn_url":"https://github.com/ceshihao/go-grpc-middleware","homepage":"","size":13511,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"grpc-ecosystem:master","ref":"master","sha":"cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d","user":{"login":"grpc-ecosystem","id":19352526,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5MzUyNTI2","avatar_url":"https://avatars3.githubusercontent.com/u/19352526?v=4","gravatar_id":"","url":"https://api.github.com/users/grpc-ecosystem","html_url":"https://github.com/grpc-ecosystem","followers_url":"https://api.github.com/users/grpc-ecosystem/followers","following_url":"https://api.github.com/users/grpc-ecosystem/following{/other_user}","gists_url":"https://api.github.com/users/grpc-ecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc-ecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc-ecosystem/subscriptions","organizations_url":"https://api.github.com/users/grpc-ecosystem/orgs","repos_url":"https://api.github.com/users/grpc-ecosystem/repos","events_url":"https://api.github.com/users/grpc-ecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/grpc-ecosystem/received_events","type":"Organization","site_admin":false},"repo":{"id":58821882,"node_id":"MDEwOlJlcG9zaXRvcnk1ODgyMTg4Mg==","name":"go-grpc-middleware","full_name":"grpc-ecosystem/go-grpc-middleware","private":false,"owner":{"login":"grpc-ecosystem","id":19352526,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5MzUyNTI2","avatar_url":"https://avatars3.githubusercontent.com/u/19352526?v=4","gravatar_id":"","url":"https://api.github.com/users/grpc-ecosystem","html_url":"https://github.com/grpc-ecosystem","followers_url":"https://api.github.com/users/grpc-ecosystem/followers","following_url":"https://api.github.com/users/grpc-ecosystem/following{/other_user}","gists_url":"https://api.github.com/users/grpc-ecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc-ecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc-ecosystem/subscriptions","organizations_url":"https://api.github.com/users/grpc-ecosystem/orgs","repos_url":"https://api.github.com/users/grpc-ecosystem/repos","events_url":"https://api.github.com/users/grpc-ecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/grpc-ecosystem/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/grpc-ecosystem/go-grpc-middleware","description":"Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.","fork":false,"url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware","forks_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/forks","keys_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/teams","hooks_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/hooks","issue_events_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/events{/number}","events_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/events","assignees_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/assignees{/user}","branches_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/branches{/branch}","tags_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/tags","blobs_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/git/refs{/sha}","trees_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/statuses/{sha}","languages_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/languages","stargazers_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/stargazers","contributors_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/contributors","subscribers_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/subscribers","subscription_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/subscription","commits_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/commits{/sha}","git_commits_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/git/commits{/sha}","comments_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/comments{/number}","issue_comment_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/comments{/number}","contents_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/contents/{+path}","compare_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/merges","archive_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/downloads","issues_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues{/number}","pulls_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls{/number}","milestones_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/milestones{/number}","notifications_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/labels{/name}","releases_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/releases{/id}","deployments_url":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/deployments","created_at":"2016-05-14T17:48:56Z","updated_at":"2019-05-21T10:05:18Z","pushed_at":"2019-05-21T13:48:34Z","git_url":"git://github.com/grpc-ecosystem/go-grpc-middleware.git","ssh_url":"git@github.com:grpc-ecosystem/go-grpc-middleware.git","clone_url":"https://github.com/grpc-ecosystem/go-grpc-middleware.git","svn_url":"https://github.com/grpc-ecosystem/go-grpc-middleware","homepage":"","size":13502,"stargazers_count":1769,"watchers_count":1769,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":234,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":67,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":234,"open_issues":67,"watchers":1769,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181"},"html":{"href":"https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181"},"issue":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/181"},"comments":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/issues/181/comments"},"review_comments":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181/comments"},"review_comment":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/pulls/181/commits"},"statuses":{"href":"https://api.github.com/repos/grpc-ecosystem/go-grpc-middleware/statuses/4b75c008f6218ea7e097a124e8b8e47502c64235"}},"author_association":"NONE"}}
other: {"actor":{"display_login":"domgreen"}}