{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/comments/198438315","pull_request_review_id":132366520,"id":198438315,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODQzODMxNQ==","diff_hunk":"@@ -2055,4 +2085,139 @@ mod tests {\n             }\n         }\n     }\n+\n+    #[allow(useless_vec)]\n+    #[test]\n+    fn test_request_inspector() {\n+        struct DummyInspector {\n+            applied_index_term: bool,\n+            lease_state: LeaseState,\n+        }\n+        impl RequestInspector for DummyInspector {\n+            fn has_applied_current_term(&self) -> bool {\n+                self.applied_index_term\n+            }\n+            fn inspect_lease(&mut self) -> LeaseState {\n+                self.lease_state.clone()\n+            }\n+        }\n+\n+        let mut table = vec![];\n+\n+        // Ok(_)\n+        let mut req = RaftCmdRequest::new();\n+        let mut admin_req = raft_cmdpb::AdminRequest::new();\n+\n+        req.set_admin_request(admin_req.clone());\n+        table.push((req.clone(), RequestPolicy::ProposeNormal));\n+\n+        admin_req.set_change_peer(raft_cmdpb::ChangePeerRequest::new());\n+        req.set_admin_request(admin_req.clone());\n+        table.push((req.clone(), RequestPolicy::ProposeConfChange));\n+        admin_req.clear_change_peer();\n+\n+        admin_req.set_transfer_leader(raft_cmdpb::TransferLeaderRequest::new());\n+        req.set_admin_request(admin_req.clone());\n+        table.push((req.clone(), RequestPolicy::ProposeTransferLeader));\n+        admin_req.clear_transfer_leader();\n+        req.clear_admin_request();\n+\n+        for (op, policy) in vec![\n+            (CmdType::Get, RequestPolicy::ReadLocal),\n+            (CmdType::Snap, RequestPolicy::ReadLocal),\n+            (CmdType::Put, RequestPolicy::ProposeNormal),\n+            (CmdType::Delete, RequestPolicy::ProposeNormal),\n+            (CmdType::DeleteRange, RequestPolicy::ProposeNormal),\n+            (CmdType::IngestSST, RequestPolicy::ProposeNormal),\n+        ] {\n+            let mut request = raft_cmdpb::Request::new();\n+            request.set_cmd_type(op);\n+            req.set_requests(vec![request].into());\n+            table.push((req.clone(), policy));\n+        }\n+\n+        for b in vec![true, false] {","path":"src/raftstore/store/peer.rs","position":278,"original_position":278,"commit_id":"60cc495beb78c492fdd05c5319e065f6a0570b7a","original_commit_id":"60cc495beb78c492fdd05c5319e065f6a0570b7a","user":{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"body":"After listing them one by one, the tests becoms to long, instead, I will add some comments to make it more clear.","created_at":"2018-06-27T10:06:45Z","updated_at":"2018-06-27T10:06:45Z","html_url":"https://github.com/pingcap/tikv/pull/3193#discussion_r198438315","pull_request_url":"https://api.github.com/repos/pingcap/tikv/pulls/3193","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments/198438315"},"html":{"href":"https://github.com/pingcap/tikv/pull/3193#discussion_r198438315"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/3193"}},"in_reply_to_id":198423188},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/3193","id":194243194,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0MjQzMTk0","html_url":"https://github.com/pingcap/tikv/pull/3193","diff_url":"https://github.com/pingcap/tikv/pull/3193.diff","patch_url":"https://github.com/pingcap/tikv/pull/3193.patch","issue_url":"https://api.github.com/repos/pingcap/tikv/issues/3193","number":3193,"state":"open","locked":false,"title":"raftstore: add RequestInspector to decide how to handle requests","user":{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"body":"What have you changed? (mandatory)\r\n\r\nAdd a struct to decouple `get_handle_policy` from `Peer`, #2639  needs it to handle requests.\r\n\r\nRefer to a related PR or issue link (optional)\r\n\r\n#2639 \r\n\r\n","created_at":"2018-06-12T11:04:04Z","updated_at":"2018-06-27T10:06:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d20282579403d98a73cbd1e813fdca578fcf5c1","assignee":null,"assignees":[],"requested_reviewers":[{"login":"siddontang","id":1080370,"node_id":"MDQ6VXNlcjEwODAzNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/1080370?v=4","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},{"login":"hicqu","id":8407317,"node_id":"MDQ6VXNlcjg0MDczMTc=","avatar_url":"https://avatars1.githubusercontent.com/u/8407317?v=4","gravatar_id":"","url":"https://api.github.com/users/hicqu","html_url":"https://github.com/hicqu","followers_url":"https://api.github.com/users/hicqu/followers","following_url":"https://api.github.com/users/hicqu/following{/other_user}","gists_url":"https://api.github.com/users/hicqu/gists{/gist_id}","starred_url":"https://api.github.com/users/hicqu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hicqu/subscriptions","organizations_url":"https://api.github.com/users/hicqu/orgs","repos_url":"https://api.github.com/users/hicqu/repos","events_url":"https://api.github.com/users/hicqu/events{/privacy}","received_events_url":"https://api.github.com/users/hicqu/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv/pulls/3193/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv/pulls/3193/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv/issues/3193/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/60cc495beb78c492fdd05c5319e065f6a0570b7a","head":{"label":"overvenus:read/judge","ref":"read/judge","sha":"60cc495beb78c492fdd05c5319e065f6a0570b7a","user":{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"repo":{"id":58031891,"node_id":"MDEwOlJlcG9zaXRvcnk1ODAzMTg5MQ==","name":"tikv","full_name":"overvenus/tikv","owner":{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/overvenus/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":true,"url":"https://api.github.com/repos/overvenus/tikv","forks_url":"https://api.github.com/repos/overvenus/tikv/forks","keys_url":"https://api.github.com/repos/overvenus/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/overvenus/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/overvenus/tikv/teams","hooks_url":"https://api.github.com/repos/overvenus/tikv/hooks","issue_events_url":"https://api.github.com/repos/overvenus/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/overvenus/tikv/events","assignees_url":"https://api.github.com/repos/overvenus/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/overvenus/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/overvenus/tikv/tags","blobs_url":"https://api.github.com/repos/overvenus/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/overvenus/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/overvenus/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/overvenus/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/overvenus/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/overvenus/tikv/languages","stargazers_url":"https://api.github.com/repos/overvenus/tikv/stargazers","contributors_url":"https://api.github.com/repos/overvenus/tikv/contributors","subscribers_url":"https://api.github.com/repos/overvenus/tikv/subscribers","subscription_url":"https://api.github.com/repos/overvenus/tikv/subscription","commits_url":"https://api.github.com/repos/overvenus/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/overvenus/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/overvenus/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/overvenus/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/overvenus/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/overvenus/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/overvenus/tikv/merges","archive_url":"https://api.github.com/repos/overvenus/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/overvenus/tikv/downloads","issues_url":"https://api.github.com/repos/overvenus/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/overvenus/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/overvenus/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/overvenus/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/overvenus/tikv/labels{/name}","releases_url":"https://api.github.com/repos/overvenus/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/overvenus/tikv/deployments","created_at":"2016-05-04T07:29:33Z","updated_at":"2017-08-09T14:18:39Z","pushed_at":"2018-06-27T09:21:38Z","git_url":"git://github.com/overvenus/tikv.git","ssh_url":"git@github.com:overvenus/tikv.git","clone_url":"https://github.com/overvenus/tikv.git","svn_url":"https://github.com/overvenus/tikv","homepage":"","size":13791,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":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":"pingcap:master","ref":"master","sha":"fe01bf9ba732e780639be01b8e346ed7ba1990d6","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"node_id":"MDEwOlJlcG9zaXRvcnk0ODgzMzkxMA==","name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2018-06-27T07:52:16Z","pushed_at":"2018-06-27T10:01:43Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"https://pingcap.com","size":14232,"stargazers_count":3312,"watchers_count":3312,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":422,"mirror_url":null,"archived":false,"open_issues_count":219,"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":422,"open_issues":219,"watchers":3312,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/3193"},"html":{"href":"https://github.com/pingcap/tikv/pull/3193"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv/issues/3193"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv/issues/3193/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/3193/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/3193/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv/statuses/60cc495beb78c492fdd05c5319e065f6a0570b7a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"overvenus"}}