{"action":"created","comment":{"url":"https://api.github.com/repos/runconduit/conduit/pulls/comments/186828148","pull_request_review_id":118483505,"id":186828148,"diff_hunk":"@@ -380,3 +415,65 @@ fn parse<T, Parse>(strings: &Strings, name: &str, parse: Parse) -> Result<Option\n         None => Ok(None),\n     }\n }\n+\n+#[cfg(test)]\n+mod tests {\n+    use super::*;\n+\n+    fn test_units<F: Fn(u64) -> Duration>(units: &[&str], to_duration: F) {\n+        for v in &[1, 23, 456_789] {\n+            let d = to_duration(*v);\n+            for u in units {\n+                let text = format!(\"{}{}\", v, u);\n+                assert_eq!(parse_duration(&text), Ok(d), \"text=\\\"{}\\\"\", text);\n+\n+                let text = format!(\"{} {}\", v, u);\n+                assert_eq!(parse_duration(&text), Ok(d), \"text=\\\"{}\\\"\", text);\n+\n+                let text = format!(\" {}  {} \", v, u);\n+                assert_eq!(parse_duration(&text), Ok(d), \"text=\\\"{}\\\"\", text);\n+            }\n+        }\n+    }\n+\n+    #[test]\n+    fn parse_duration_milliseconds() {\n+        let units = [\"ms\", \"msec\", \"msecs\", \"milli\", \"millis\", \"millisecond\", \"milliseconds\"];\n+        test_units(&units, |v| Duration::from_millis(v));\n+    }\n+\n+    #[test]\n+    fn parse_duration_seconds() {\n+        let units = [\"s\", \"sec\", \"secs\", \"second\", \"seconds\"];\n+        test_units(&units, |v| Duration::from_secs(v));\n+    }\n+\n+    #[test]\n+    fn parse_duration_minutes() {\n+        let units = [\"m\", \"min\", \"mins\", \"minute\", \"minutes\"];\n+        test_units(&units, |v| Duration::from_secs(v * 60));\n+    }\n+\n+    #[test]\n+    fn parse_duration_hours() {\n+        let units = [\"h\", \"hour\", \"hours\"];\n+        test_units(&units, |v| Duration::from_secs(v * 60 * 60));\n+    }\n+\n+    #[test]\n+    fn parse_duration_days() {\n+        let units = [\"d\", \"day\", \"days\"];\n+        test_units(&units, |v| Duration::from_secs(v * 60 * 60 * 24));\n+    }\n+\n+    #[test]\n+    fn parse_float_numbers_are_invalid() {\n+        assert_eq!(parse_duration(\".123 hours\"), Err(ParseError::NotADuration));\n+        assert_eq!(parse_duration(\"1.23 hours\"), Err(ParseError::NotADuration));\n+    }\n+\n+    #[test]\n+    fn parse_invalid_unit() {\n+        assert_eq!(parse_duration(\"12 moons\"), Err(ParseError::NotADuration));\n+    }","path":"proxy/src/config.rs","position":174,"original_position":174,"commit_id":"1001a91530b70004ae061cf0c5e4f43afe74caf7","original_commit_id":"1001a91530b70004ae061cf0c5e4f43afe74caf7","user":{"login":"briansmith","id":16816,"avatar_url":"https://avatars0.githubusercontent.com/u/16816?v=4","gravatar_id":"","url":"https://api.github.com/users/briansmith","html_url":"https://github.com/briansmith","followers_url":"https://api.github.com/users/briansmith/followers","following_url":"https://api.github.com/users/briansmith/following{/other_user}","gists_url":"https://api.github.com/users/briansmith/gists{/gist_id}","starred_url":"https://api.github.com/users/briansmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briansmith/subscriptions","organizations_url":"https://api.github.com/users/briansmith/orgs","repos_url":"https://api.github.com/users/briansmith/repos","events_url":"https://api.github.com/users/briansmith/events{/privacy}","received_events_url":"https://api.github.com/users/briansmith/received_events","type":"User","site_admin":false},"body":"We should also have a test for the input string that would cause a overflow, as well as for the maximum value that won't cause an overflow. Also negative numbers.","created_at":"2018-05-08T18:42:16Z","updated_at":"2018-05-08T18:43:12Z","html_url":"https://github.com/runconduit/conduit/pull/909#discussion_r186828148","pull_request_url":"https://api.github.com/repos/runconduit/conduit/pulls/909","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/comments/186828148"},"html":{"href":"https://github.com/runconduit/conduit/pull/909#discussion_r186828148"},"pull_request":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/909"}}},"pull_request":{"url":"https://api.github.com/repos/runconduit/conduit/pulls/909","id":186709865,"html_url":"https://github.com/runconduit/conduit/pull/909","diff_url":"https://github.com/runconduit/conduit/pull/909.diff","patch_url":"https://github.com/runconduit/conduit/pull/909.patch","issue_url":"https://api.github.com/repos/runconduit/conduit/issues/909","number":909,"state":"open","locked":false,"title":"proxy: Parse units with duration configurations","user":{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false},"body":"Configuration values that take durations are currently specified as\r\ntime values with no units.  So `600` may mean 600ms in some contexts and\r\n10 minutes in others.\r\n\r\nIn order to avoid this problem, this change now requires that\r\nconfigurations provide explicit units for time values such as '600ms' or\r\n'10 minutes'.\r\n\r\nAfter this, users may set environment vars like `CONDUIT_PROXY_METRICS_RETAIN_IDLE=\"1h\"`.","created_at":"2018-05-08T17:56:24Z","updated_at":"2018-05-08T18:43:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2166be220f68b559f3f39613fa89e150e47a8ef7","assignee":{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false},"assignees":[{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"seanmonstar","id":51479,"avatar_url":"https://avatars1.githubusercontent.com/u/51479?v=4","gravatar_id":"","url":"https://api.github.com/users/seanmonstar","html_url":"https://github.com/seanmonstar","followers_url":"https://api.github.com/users/seanmonstar/followers","following_url":"https://api.github.com/users/seanmonstar/following{/other_user}","gists_url":"https://api.github.com/users/seanmonstar/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmonstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmonstar/subscriptions","organizations_url":"https://api.github.com/users/seanmonstar/orgs","repos_url":"https://api.github.com/users/seanmonstar/repos","events_url":"https://api.github.com/users/seanmonstar/events{/privacy}","received_events_url":"https://api.github.com/users/seanmonstar/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":773709989,"url":"https://api.github.com/repos/runconduit/conduit/labels/area/proxy","name":"area/proxy","color":"0052CC","default":false}],"milestone":{"url":"https://api.github.com/repos/runconduit/conduit/milestones/7","html_url":"https://github.com/runconduit/conduit/milestone/7","labels_url":"https://api.github.com/repos/runconduit/conduit/milestones/7/labels","id":3134345,"number":7,"title":"0.5.0","description":"Controllable Deadlines/Timeouts","creator":{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false},"open_issues":58,"closed_issues":19,"state":"open","created_at":"2018-02-21T19:35:41Z","updated_at":"2018-05-08T17:58:23Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/runconduit/conduit/pulls/909/commits","review_comments_url":"https://api.github.com/repos/runconduit/conduit/pulls/909/comments","review_comment_url":"https://api.github.com/repos/runconduit/conduit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/runconduit/conduit/issues/909/comments","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/1001a91530b70004ae061cf0c5e4f43afe74caf7","head":{"label":"runconduit:ver/config-parse-durations","ref":"ver/config-parse-durations","sha":"1001a91530b70004ae061cf0c5e4f43afe74caf7","user":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"repo":{"id":113106184,"name":"conduit","full_name":"runconduit/conduit","owner":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/runconduit/conduit","description":"Ultralight service mesh for Kubernetes","fork":false,"url":"https://api.github.com/repos/runconduit/conduit","forks_url":"https://api.github.com/repos/runconduit/conduit/forks","keys_url":"https://api.github.com/repos/runconduit/conduit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runconduit/conduit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runconduit/conduit/teams","hooks_url":"https://api.github.com/repos/runconduit/conduit/hooks","issue_events_url":"https://api.github.com/repos/runconduit/conduit/issues/events{/number}","events_url":"https://api.github.com/repos/runconduit/conduit/events","assignees_url":"https://api.github.com/repos/runconduit/conduit/assignees{/user}","branches_url":"https://api.github.com/repos/runconduit/conduit/branches{/branch}","tags_url":"https://api.github.com/repos/runconduit/conduit/tags","blobs_url":"https://api.github.com/repos/runconduit/conduit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runconduit/conduit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runconduit/conduit/git/refs{/sha}","trees_url":"https://api.github.com/repos/runconduit/conduit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/{sha}","languages_url":"https://api.github.com/repos/runconduit/conduit/languages","stargazers_url":"https://api.github.com/repos/runconduit/conduit/stargazers","contributors_url":"https://api.github.com/repos/runconduit/conduit/contributors","subscribers_url":"https://api.github.com/repos/runconduit/conduit/subscribers","subscription_url":"https://api.github.com/repos/runconduit/conduit/subscription","commits_url":"https://api.github.com/repos/runconduit/conduit/commits{/sha}","git_commits_url":"https://api.github.com/repos/runconduit/conduit/git/commits{/sha}","comments_url":"https://api.github.com/repos/runconduit/conduit/comments{/number}","issue_comment_url":"https://api.github.com/repos/runconduit/conduit/issues/comments{/number}","contents_url":"https://api.github.com/repos/runconduit/conduit/contents/{+path}","compare_url":"https://api.github.com/repos/runconduit/conduit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runconduit/conduit/merges","archive_url":"https://api.github.com/repos/runconduit/conduit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runconduit/conduit/downloads","issues_url":"https://api.github.com/repos/runconduit/conduit/issues{/number}","pulls_url":"https://api.github.com/repos/runconduit/conduit/pulls{/number}","milestones_url":"https://api.github.com/repos/runconduit/conduit/milestones{/number}","notifications_url":"https://api.github.com/repos/runconduit/conduit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runconduit/conduit/labels{/name}","releases_url":"https://api.github.com/repos/runconduit/conduit/releases{/id}","deployments_url":"https://api.github.com/repos/runconduit/conduit/deployments","created_at":"2017-12-04T23:16:56Z","updated_at":"2018-05-08T18:11:10Z","pushed_at":"2018-05-08T18:20:17Z","git_url":"git://github.com/runconduit/conduit.git","ssh_url":"git@github.com:runconduit/conduit.git","clone_url":"https://github.com/runconduit/conduit.git","svn_url":"https://github.com/runconduit/conduit","homepage":"https://conduit.io","size":4705,"stargazers_count":1614,"watchers_count":1614,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"archived":false,"open_issues_count":166,"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":88,"open_issues":166,"watchers":1614,"default_branch":"master"}},"base":{"label":"runconduit:master","ref":"master","sha":"68e203a2fc9c47b396a984588c90a2dfd2b2c543","user":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"repo":{"id":113106184,"name":"conduit","full_name":"runconduit/conduit","owner":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/runconduit/conduit","description":"Ultralight service mesh for Kubernetes","fork":false,"url":"https://api.github.com/repos/runconduit/conduit","forks_url":"https://api.github.com/repos/runconduit/conduit/forks","keys_url":"https://api.github.com/repos/runconduit/conduit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runconduit/conduit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runconduit/conduit/teams","hooks_url":"https://api.github.com/repos/runconduit/conduit/hooks","issue_events_url":"https://api.github.com/repos/runconduit/conduit/issues/events{/number}","events_url":"https://api.github.com/repos/runconduit/conduit/events","assignees_url":"https://api.github.com/repos/runconduit/conduit/assignees{/user}","branches_url":"https://api.github.com/repos/runconduit/conduit/branches{/branch}","tags_url":"https://api.github.com/repos/runconduit/conduit/tags","blobs_url":"https://api.github.com/repos/runconduit/conduit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runconduit/conduit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runconduit/conduit/git/refs{/sha}","trees_url":"https://api.github.com/repos/runconduit/conduit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/{sha}","languages_url":"https://api.github.com/repos/runconduit/conduit/languages","stargazers_url":"https://api.github.com/repos/runconduit/conduit/stargazers","contributors_url":"https://api.github.com/repos/runconduit/conduit/contributors","subscribers_url":"https://api.github.com/repos/runconduit/conduit/subscribers","subscription_url":"https://api.github.com/repos/runconduit/conduit/subscription","commits_url":"https://api.github.com/repos/runconduit/conduit/commits{/sha}","git_commits_url":"https://api.github.com/repos/runconduit/conduit/git/commits{/sha}","comments_url":"https://api.github.com/repos/runconduit/conduit/comments{/number}","issue_comment_url":"https://api.github.com/repos/runconduit/conduit/issues/comments{/number}","contents_url":"https://api.github.com/repos/runconduit/conduit/contents/{+path}","compare_url":"https://api.github.com/repos/runconduit/conduit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runconduit/conduit/merges","archive_url":"https://api.github.com/repos/runconduit/conduit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runconduit/conduit/downloads","issues_url":"https://api.github.com/repos/runconduit/conduit/issues{/number}","pulls_url":"https://api.github.com/repos/runconduit/conduit/pulls{/number}","milestones_url":"https://api.github.com/repos/runconduit/conduit/milestones{/number}","notifications_url":"https://api.github.com/repos/runconduit/conduit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runconduit/conduit/labels{/name}","releases_url":"https://api.github.com/repos/runconduit/conduit/releases{/id}","deployments_url":"https://api.github.com/repos/runconduit/conduit/deployments","created_at":"2017-12-04T23:16:56Z","updated_at":"2018-05-08T18:11:10Z","pushed_at":"2018-05-08T18:20:17Z","git_url":"git://github.com/runconduit/conduit.git","ssh_url":"git@github.com:runconduit/conduit.git","clone_url":"https://github.com/runconduit/conduit.git","svn_url":"https://github.com/runconduit/conduit","homepage":"https://conduit.io","size":4705,"stargazers_count":1614,"watchers_count":1614,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"archived":false,"open_issues_count":166,"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":88,"open_issues":166,"watchers":1614,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/909"},"html":{"href":"https://github.com/runconduit/conduit/pull/909"},"issue":{"href":"https://api.github.com/repos/runconduit/conduit/issues/909"},"comments":{"href":"https://api.github.com/repos/runconduit/conduit/issues/909/comments"},"review_comments":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/909/comments"},"review_comment":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/909/commits"},"statuses":{"href":"https://api.github.com/repos/runconduit/conduit/statuses/1001a91530b70004ae061cf0c5e4f43afe74caf7"}},"author_association":"OWNER"}}
{"actor":{"display_login":"briansmith"}}