{"action":"created","comment":{"url":"https://api.github.com/repos/alibaba/pouch/pulls/comments/172079631","pull_request_review_id":101035328,"id":172079631,"diff_hunk":"@@ -0,0 +1,125 @@\n+package stream\n+\n+import (\n+\t\"container/list\"\n+\t\"crypto/rand\"\n+\t\"encoding/base64\"\n+\t\"fmt\"\n+\t\"math\"\n+\t\"sync\"\n+\t\"time\"\n+)\n+\n+var (\n+\t// CacheTTL is timeout after which tokens become invalid.\n+\tCacheTTL = 1 * time.Minute\n+\t// MaxInFlight is the maximum number of in-flight requests to allow.\n+\tMaxInFlight = 1000\n+\t// TokenLen is the length of the random base64 encoded token identifying the request.\n+\tTokenLen = 8\n+)\n+\n+// requestCache caches streaming (exec/attach/port-forward) requests and generates a single-use\n+// random token for their retrieval. The requestCache is used for building streaming URLs without\n+// the need to encode every request parameter in the URL.\n+type requestCache struct {\n+\t// tokens maps the generate token to the request for fast retrieval.\n+\ttokens map[string]*list.Element\n+\t// ll maintains an age-ordered request list for faster garbage collection of expired requests.\n+\tll *list.List\n+\n+\tlock sync.Mutex\n+}\n+\n+// Type representing an *ExecRequest, *AttachRequest, or *PortForwardRequest.\n+type request interface{}\n+\n+type cacheEntry struct {\n+\ttoken      string\n+\treq        request\n+\texpireTime time.Time\n+}\n+\n+func newRequestCache() *requestCache {\n+\treturn &requestCache{\n+\t\tll:     list.New(),\n+\t\ttokens: make(map[string]*list.Element),\n+\t}\n+}\n+\n+// Insert the given request into the cache and returns the token used for fetching it out.\n+func (c *requestCache) Insert(req request) (token string, err error) {\n+\tc.lock.Lock()","path":"cri/stream/request_cache.go","position":52,"original_position":52,"commit_id":"3a578c0a1a511cd9a8d7ac2dabc188ffdbd2665c","original_commit_id":"3a578c0a1a511cd9a8d7ac2dabc188ffdbd2665c","user":{"login":"allencloud","id":9465626,"avatar_url":"https://avatars3.githubusercontent.com/u/9465626?v=4","gravatar_id":"","url":"https://api.github.com/users/allencloud","html_url":"https://github.com/allencloud","followers_url":"https://api.github.com/users/allencloud/followers","following_url":"https://api.github.com/users/allencloud/following{/other_user}","gists_url":"https://api.github.com/users/allencloud/gists{/gist_id}","starred_url":"https://api.github.com/users/allencloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allencloud/subscriptions","organizations_url":"https://api.github.com/users/allencloud/orgs","repos_url":"https://api.github.com/users/allencloud/repos","events_url":"https://api.github.com/users/allencloud/events{/privacy}","received_events_url":"https://api.github.com/users/allencloud/received_events","type":"User","site_admin":false},"body":"I am wondering if this lock is locking two much actions, not only data. Just add a comment, since no testing data no bb. Not blocking.","created_at":"2018-03-05T02:26:28Z","updated_at":"2018-03-05T02:26:28Z","html_url":"https://github.com/alibaba/pouch/pull/797#discussion_r172079631","pull_request_url":"https://api.github.com/repos/alibaba/pouch/pulls/797","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/comments/172079631"},"html":{"href":"https://github.com/alibaba/pouch/pull/797#discussion_r172079631"},"pull_request":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/797"}}},"pull_request":{"url":"https://api.github.com/repos/alibaba/pouch/pulls/797","id":172133875,"html_url":"https://github.com/alibaba/pouch/pull/797","diff_url":"https://github.com/alibaba/pouch/pull/797.diff","patch_url":"https://github.com/alibaba/pouch/pull/797.patch","issue_url":"https://api.github.com/repos/alibaba/pouch/issues/797","number":797,"state":"open","locked":false,"title":"feature: basic framework of stream server for cri manager","user":{"login":"YaoZengzeng","id":8636562,"avatar_url":"https://avatars1.githubusercontent.com/u/8636562?v=4","gravatar_id":"","url":"https://api.github.com/users/YaoZengzeng","html_url":"https://github.com/YaoZengzeng","followers_url":"https://api.github.com/users/YaoZengzeng/followers","following_url":"https://api.github.com/users/YaoZengzeng/following{/other_user}","gists_url":"https://api.github.com/users/YaoZengzeng/gists{/gist_id}","starred_url":"https://api.github.com/users/YaoZengzeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaoZengzeng/subscriptions","organizations_url":"https://api.github.com/users/YaoZengzeng/orgs","repos_url":"https://api.github.com/users/YaoZengzeng/repos","events_url":"https://api.github.com/users/YaoZengzeng/events{/privacy}","received_events_url":"https://api.github.com/users/YaoZengzeng/received_events","type":"User","site_admin":false},"body":"Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>\r\n\r\n<!-- \r\nPlease make sure you have read and understood the contributing guidelines;\r\nhttps://github.com/alibaba/pouch/blob/master/CONTRIBUTING.md -->\r\n\r\n### Ⅰ. Describe what this PR did\r\n\r\nThis PR will implement the stream server and Exec method of CRI manager.\r\n\r\nThe other two stream server related method Attach and PortForward will be implemented in other PRs\r\n\r\n\r\n### Ⅱ. Does this pull request fix one issue?\r\n<!--If that, add \"fixes #xxxx\" below in the next line, for example, fixes #15. Otherwise, add \"NONE\" -->\r\n\r\nfixes part of #420 \r\n\r\n\r\n### Ⅲ. Describe how you did it\r\n\r\n\r\n### Ⅳ. Describe how to verify it\r\n\r\n\r\n### Ⅴ. Special notes for reviews\r\n\r\n\r\n","created_at":"2018-03-01T03:21:35Z","updated_at":"2018-03-05T02:26:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd62f4aa45b220655ac22b8e8bf042fc070de02f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":722348097,"url":"https://api.github.com/repos/alibaba/pouch/labels/kind/feature","name":"kind/feature","color":"1d76db","default":false},{"id":722355711,"url":"https://api.github.com/repos/alibaba/pouch/labels/size/XXL","name":"size/XXL","color":"cc3d73","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/alibaba/pouch/pulls/797/commits","review_comments_url":"https://api.github.com/repos/alibaba/pouch/pulls/797/comments","review_comment_url":"https://api.github.com/repos/alibaba/pouch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alibaba/pouch/issues/797/comments","statuses_url":"https://api.github.com/repos/alibaba/pouch/statuses/3a578c0a1a511cd9a8d7ac2dabc188ffdbd2665c","head":{"label":"YaoZengzeng:streaming-server","ref":"streaming-server","sha":"3a578c0a1a511cd9a8d7ac2dabc188ffdbd2665c","user":{"login":"YaoZengzeng","id":8636562,"avatar_url":"https://avatars1.githubusercontent.com/u/8636562?v=4","gravatar_id":"","url":"https://api.github.com/users/YaoZengzeng","html_url":"https://github.com/YaoZengzeng","followers_url":"https://api.github.com/users/YaoZengzeng/followers","following_url":"https://api.github.com/users/YaoZengzeng/following{/other_user}","gists_url":"https://api.github.com/users/YaoZengzeng/gists{/gist_id}","starred_url":"https://api.github.com/users/YaoZengzeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaoZengzeng/subscriptions","organizations_url":"https://api.github.com/users/YaoZengzeng/orgs","repos_url":"https://api.github.com/users/YaoZengzeng/repos","events_url":"https://api.github.com/users/YaoZengzeng/events{/privacy}","received_events_url":"https://api.github.com/users/YaoZengzeng/received_events","type":"User","site_admin":false},"repo":{"id":111785477,"name":"pouch","full_name":"YaoZengzeng/pouch","owner":{"login":"YaoZengzeng","id":8636562,"avatar_url":"https://avatars1.githubusercontent.com/u/8636562?v=4","gravatar_id":"","url":"https://api.github.com/users/YaoZengzeng","html_url":"https://github.com/YaoZengzeng","followers_url":"https://api.github.com/users/YaoZengzeng/followers","following_url":"https://api.github.com/users/YaoZengzeng/following{/other_user}","gists_url":"https://api.github.com/users/YaoZengzeng/gists{/gist_id}","starred_url":"https://api.github.com/users/YaoZengzeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaoZengzeng/subscriptions","organizations_url":"https://api.github.com/users/YaoZengzeng/orgs","repos_url":"https://api.github.com/users/YaoZengzeng/repos","events_url":"https://api.github.com/users/YaoZengzeng/events{/privacy}","received_events_url":"https://api.github.com/users/YaoZengzeng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/YaoZengzeng/pouch","description":"Pouch is an open-source project created to promote the container technology movement.","fork":true,"url":"https://api.github.com/repos/YaoZengzeng/pouch","forks_url":"https://api.github.com/repos/YaoZengzeng/pouch/forks","keys_url":"https://api.github.com/repos/YaoZengzeng/pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YaoZengzeng/pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YaoZengzeng/pouch/teams","hooks_url":"https://api.github.com/repos/YaoZengzeng/pouch/hooks","issue_events_url":"https://api.github.com/repos/YaoZengzeng/pouch/issues/events{/number}","events_url":"https://api.github.com/repos/YaoZengzeng/pouch/events","assignees_url":"https://api.github.com/repos/YaoZengzeng/pouch/assignees{/user}","branches_url":"https://api.github.com/repos/YaoZengzeng/pouch/branches{/branch}","tags_url":"https://api.github.com/repos/YaoZengzeng/pouch/tags","blobs_url":"https://api.github.com/repos/YaoZengzeng/pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YaoZengzeng/pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YaoZengzeng/pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/YaoZengzeng/pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YaoZengzeng/pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/YaoZengzeng/pouch/languages","stargazers_url":"https://api.github.com/repos/YaoZengzeng/pouch/stargazers","contributors_url":"https://api.github.com/repos/YaoZengzeng/pouch/contributors","subscribers_url":"https://api.github.com/repos/YaoZengzeng/pouch/subscribers","subscription_url":"https://api.github.com/repos/YaoZengzeng/pouch/subscription","commits_url":"https://api.github.com/repos/YaoZengzeng/pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/YaoZengzeng/pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/YaoZengzeng/pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/YaoZengzeng/pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/YaoZengzeng/pouch/contents/{+path}","compare_url":"https://api.github.com/repos/YaoZengzeng/pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YaoZengzeng/pouch/merges","archive_url":"https://api.github.com/repos/YaoZengzeng/pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YaoZengzeng/pouch/downloads","issues_url":"https://api.github.com/repos/YaoZengzeng/pouch/issues{/number}","pulls_url":"https://api.github.com/repos/YaoZengzeng/pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/YaoZengzeng/pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/YaoZengzeng/pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YaoZengzeng/pouch/labels{/name}","releases_url":"https://api.github.com/repos/YaoZengzeng/pouch/releases{/id}","deployments_url":"https://api.github.com/repos/YaoZengzeng/pouch/deployments","created_at":"2017-11-23T08:50:18Z","updated_at":"2017-11-23T08:50:21Z","pushed_at":"2018-03-02T08:05:09Z","git_url":"git://github.com/YaoZengzeng/pouch.git","ssh_url":"git@github.com:YaoZengzeng/pouch.git","clone_url":"https://github.com/YaoZengzeng/pouch.git","svn_url":"https://github.com/YaoZengzeng/pouch","homepage":"","size":9490,"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,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alibaba:master","ref":"master","sha":"16fb07178c25942383d2fcc2cb989d96ad7d70ce","user":{"login":"alibaba","id":1961952,"avatar_url":"https://avatars1.githubusercontent.com/u/1961952?v=4","gravatar_id":"","url":"https://api.github.com/users/alibaba","html_url":"https://github.com/alibaba","followers_url":"https://api.github.com/users/alibaba/followers","following_url":"https://api.github.com/users/alibaba/following{/other_user}","gists_url":"https://api.github.com/users/alibaba/gists{/gist_id}","starred_url":"https://api.github.com/users/alibaba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alibaba/subscriptions","organizations_url":"https://api.github.com/users/alibaba/orgs","repos_url":"https://api.github.com/users/alibaba/repos","events_url":"https://api.github.com/users/alibaba/events{/privacy}","received_events_url":"https://api.github.com/users/alibaba/received_events","type":"Organization","site_admin":false},"repo":{"id":102555965,"name":"pouch","full_name":"alibaba/pouch","owner":{"login":"alibaba","id":1961952,"avatar_url":"https://avatars1.githubusercontent.com/u/1961952?v=4","gravatar_id":"","url":"https://api.github.com/users/alibaba","html_url":"https://github.com/alibaba","followers_url":"https://api.github.com/users/alibaba/followers","following_url":"https://api.github.com/users/alibaba/following{/other_user}","gists_url":"https://api.github.com/users/alibaba/gists{/gist_id}","starred_url":"https://api.github.com/users/alibaba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alibaba/subscriptions","organizations_url":"https://api.github.com/users/alibaba/orgs","repos_url":"https://api.github.com/users/alibaba/repos","events_url":"https://api.github.com/users/alibaba/events{/privacy}","received_events_url":"https://api.github.com/users/alibaba/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alibaba/pouch","description":"Pouch is an open-source project created to promote the container technology movement.","fork":false,"url":"https://api.github.com/repos/alibaba/pouch","forks_url":"https://api.github.com/repos/alibaba/pouch/forks","keys_url":"https://api.github.com/repos/alibaba/pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alibaba/pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alibaba/pouch/teams","hooks_url":"https://api.github.com/repos/alibaba/pouch/hooks","issue_events_url":"https://api.github.com/repos/alibaba/pouch/issues/events{/number}","events_url":"https://api.github.com/repos/alibaba/pouch/events","assignees_url":"https://api.github.com/repos/alibaba/pouch/assignees{/user}","branches_url":"https://api.github.com/repos/alibaba/pouch/branches{/branch}","tags_url":"https://api.github.com/repos/alibaba/pouch/tags","blobs_url":"https://api.github.com/repos/alibaba/pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alibaba/pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alibaba/pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/alibaba/pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alibaba/pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/alibaba/pouch/languages","stargazers_url":"https://api.github.com/repos/alibaba/pouch/stargazers","contributors_url":"https://api.github.com/repos/alibaba/pouch/contributors","subscribers_url":"https://api.github.com/repos/alibaba/pouch/subscribers","subscription_url":"https://api.github.com/repos/alibaba/pouch/subscription","commits_url":"https://api.github.com/repos/alibaba/pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/alibaba/pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/alibaba/pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/alibaba/pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/alibaba/pouch/contents/{+path}","compare_url":"https://api.github.com/repos/alibaba/pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alibaba/pouch/merges","archive_url":"https://api.github.com/repos/alibaba/pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alibaba/pouch/downloads","issues_url":"https://api.github.com/repos/alibaba/pouch/issues{/number}","pulls_url":"https://api.github.com/repos/alibaba/pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/alibaba/pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/alibaba/pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alibaba/pouch/labels{/name}","releases_url":"https://api.github.com/repos/alibaba/pouch/releases{/id}","deployments_url":"https://api.github.com/repos/alibaba/pouch/deployments","created_at":"2017-09-06T03:01:51Z","updated_at":"2018-03-05T02:10:33Z","pushed_at":"2018-03-03T06:24:52Z","git_url":"git://github.com/alibaba/pouch.git","ssh_url":"git@github.com:alibaba/pouch.git","clone_url":"https://github.com/alibaba/pouch.git","svn_url":"https://github.com/alibaba/pouch","homepage":"","size":7329,"stargazers_count":2180,"watchers_count":2180,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":383,"mirror_url":null,"archived":false,"open_issues_count":91,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":383,"open_issues":91,"watchers":2180,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/797"},"html":{"href":"https://github.com/alibaba/pouch/pull/797"},"issue":{"href":"https://api.github.com/repos/alibaba/pouch/issues/797"},"comments":{"href":"https://api.github.com/repos/alibaba/pouch/issues/797/comments"},"review_comments":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/797/comments"},"review_comment":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/797/commits"},"statuses":{"href":"https://api.github.com/repos/alibaba/pouch/statuses/3a578c0a1a511cd9a8d7ac2dabc188ffdbd2665c"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"allencloud"}}