{"action":"created","comment":{"url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/comments/92929803","pull_request_review_id":11038892,"id":92929803,"diff_hunk":"@@ -118,18 +119,63 @@ public final class Connection: ConnectionProtocol {\n     }\n \n     public func open() throws {\n-        connection = PQsetdbLogin(\n-            connectionInfo.host,\n-            String(connectionInfo.port),\n-            connectionInfo.options ?? \"\",\n-            connectionInfo.tty ?? \"\",\n-            connectionInfo.databaseName,\n-            connectionInfo.username ?? \"\",\n-            connectionInfo.password ?? \"\"\n-        )\n-\n-        if let error = mostRecentError {\n-            throw error\n+        guard connection == nil else {\n+            throw ConnectionError(description: \"Connection already opened.\")\n+        }\n+        \n+        var components = URLComponents()\n+        components.scheme = \"postgres\"\n+        components.host = connectionInfo.host\n+        components.port = connectionInfo.port\n+        components.user = connectionInfo.username\n+        components.password = connectionInfo.password\n+        components.path = \"/\\(connectionInfo.databaseName)\"\n+        if let options = connectionInfo.options {\n+            components.queryItems = [URLQueryItem(name: \"options\", value: options)]\n+        }\n+        let url = components.url!.absoluteString\n+        \n+        connection = PQconnectStart(url)\n+        \n+        guard connection != nil else {\n+            throw ConnectionError(description: \"Could not allocate connection.\")\n+        }\n+        \n+        guard PQstatus(connection) != CONNECTION_BAD else {\n+            throw ConnectionError(description: \"Could not start connection.\")\n+        }\n+        \n+        fd = PQsocket(connection)\n+        guard fd >= 0 else {\n+            throw mostRecentError ?? ConnectionError(description: \"Could not get file descriptor.\")\n+        }\n+\n+        loop: while true {","path":"Sources/PostgreSQL/Connection.swift","position":87,"original_position":87,"commit_id":"eda562f896c510fb03d34845dbee323a081d1330","original_commit_id":"eda562f896c510fb03d34845dbee323a081d1330","user":{"login":"Danappelxx","id":3291251,"avatar_url":"https://avatars.githubusercontent.com/u/3291251?v=3","gravatar_id":"","url":"https://api.github.com/users/Danappelxx","html_url":"https://github.com/Danappelxx","followers_url":"https://api.github.com/users/Danappelxx/followers","following_url":"https://api.github.com/users/Danappelxx/following{/other_user}","gists_url":"https://api.github.com/users/Danappelxx/gists{/gist_id}","starred_url":"https://api.github.com/users/Danappelxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Danappelxx/subscriptions","organizations_url":"https://api.github.com/users/Danappelxx/orgs","repos_url":"https://api.github.com/users/Danappelxx/repos","events_url":"https://api.github.com/users/Danappelxx/events{/privacy}","received_events_url":"https://api.github.com/users/Danappelxx/received_events","type":"User","site_admin":false},"body":"Loop isn't nested, so I don't think a label is necessary","created_at":"2016-12-17T21:55:04Z","updated_at":"2016-12-17T22:01:40Z","html_url":"https://github.com/Zewo/PostgreSQL/pull/15#discussion_r92929803","pull_request_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/comments/92929803"},"html":{"href":"https://github.com/Zewo/PostgreSQL/pull/15#discussion_r92929803"},"pull_request":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15","id":96055722,"html_url":"https://github.com/Zewo/PostgreSQL/pull/15","diff_url":"https://github.com/Zewo/PostgreSQL/pull/15.diff","patch_url":"https://github.com/Zewo/PostgreSQL/pull/15.patch","issue_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/15","number":15,"state":"open","locked":false,"title":"Async IO with CLibvenice","user":{"login":"robertjpayne","id":214288,"avatar_url":"https://avatars.githubusercontent.com/u/214288?v=3","gravatar_id":"","url":"https://api.github.com/users/robertjpayne","html_url":"https://github.com/robertjpayne","followers_url":"https://api.github.com/users/robertjpayne/followers","following_url":"https://api.github.com/users/robertjpayne/following{/other_user}","gists_url":"https://api.github.com/users/robertjpayne/gists{/gist_id}","starred_url":"https://api.github.com/users/robertjpayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertjpayne/subscriptions","organizations_url":"https://api.github.com/users/robertjpayne/orgs","repos_url":"https://api.github.com/users/robertjpayne/repos","events_url":"https://api.github.com/users/robertjpayne/events{/privacy}","received_events_url":"https://api.github.com/users/robertjpayne/received_events","type":"User","site_admin":false},"body":"This PR makes PostgreSQL non-blocking and play nice with Libvenice:\r\n\r\n- Uses async connection\r\n- Uses async querying\r\n\r\n@Danappelxx please review 👍 ","created_at":"2016-12-01T09:48:26Z","updated_at":"2016-12-17T22:01:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ef04d95d44e93a571b83f404deb3c71e21df5a1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15/commits","review_comments_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15/comments","review_comment_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/15/comments","statuses_url":"https://api.github.com/repos/Zewo/PostgreSQL/statuses/eda562f896c510fb03d34845dbee323a081d1330","head":{"label":"Zewo:async","ref":"async","sha":"eda562f896c510fb03d34845dbee323a081d1330","user":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"repo":{"id":47654482,"name":"PostgreSQL","full_name":"Zewo/PostgreSQL","owner":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Zewo/PostgreSQL","description":"PostgreSQL database adapter (ORM included)","fork":false,"url":"https://api.github.com/repos/Zewo/PostgreSQL","forks_url":"https://api.github.com/repos/Zewo/PostgreSQL/forks","keys_url":"https://api.github.com/repos/Zewo/PostgreSQL/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zewo/PostgreSQL/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zewo/PostgreSQL/teams","hooks_url":"https://api.github.com/repos/Zewo/PostgreSQL/hooks","issue_events_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/events{/number}","events_url":"https://api.github.com/repos/Zewo/PostgreSQL/events","assignees_url":"https://api.github.com/repos/Zewo/PostgreSQL/assignees{/user}","branches_url":"https://api.github.com/repos/Zewo/PostgreSQL/branches{/branch}","tags_url":"https://api.github.com/repos/Zewo/PostgreSQL/tags","blobs_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zewo/PostgreSQL/statuses/{sha}","languages_url":"https://api.github.com/repos/Zewo/PostgreSQL/languages","stargazers_url":"https://api.github.com/repos/Zewo/PostgreSQL/stargazers","contributors_url":"https://api.github.com/repos/Zewo/PostgreSQL/contributors","subscribers_url":"https://api.github.com/repos/Zewo/PostgreSQL/subscribers","subscription_url":"https://api.github.com/repos/Zewo/PostgreSQL/subscription","commits_url":"https://api.github.com/repos/Zewo/PostgreSQL/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zewo/PostgreSQL/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zewo/PostgreSQL/contents/{+path}","compare_url":"https://api.github.com/repos/Zewo/PostgreSQL/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zewo/PostgreSQL/merges","archive_url":"https://api.github.com/repos/Zewo/PostgreSQL/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zewo/PostgreSQL/downloads","issues_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues{/number}","pulls_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls{/number}","milestones_url":"https://api.github.com/repos/Zewo/PostgreSQL/milestones{/number}","notifications_url":"https://api.github.com/repos/Zewo/PostgreSQL/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zewo/PostgreSQL/labels{/name}","releases_url":"https://api.github.com/repos/Zewo/PostgreSQL/releases{/id}","deployments_url":"https://api.github.com/repos/Zewo/PostgreSQL/deployments","created_at":"2015-12-08T22:50:36Z","updated_at":"2016-12-11T16:20:29Z","pushed_at":"2016-12-01T09:48:26Z","git_url":"git://github.com/Zewo/PostgreSQL.git","ssh_url":"git@github.com:Zewo/PostgreSQL.git","clone_url":"https://github.com/Zewo/PostgreSQL.git","svn_url":"https://github.com/Zewo/PostgreSQL","homepage":"","size":353,"stargazers_count":91,"watchers_count":91,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":1,"forks":16,"open_issues":1,"watchers":91,"default_branch":"master"}},"base":{"label":"Zewo:master","ref":"master","sha":"a3dbab5f63e834d111fa0ec5f6a33b5797abcfa8","user":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"repo":{"id":47654482,"name":"PostgreSQL","full_name":"Zewo/PostgreSQL","owner":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Zewo/PostgreSQL","description":"PostgreSQL database adapter (ORM included)","fork":false,"url":"https://api.github.com/repos/Zewo/PostgreSQL","forks_url":"https://api.github.com/repos/Zewo/PostgreSQL/forks","keys_url":"https://api.github.com/repos/Zewo/PostgreSQL/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zewo/PostgreSQL/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zewo/PostgreSQL/teams","hooks_url":"https://api.github.com/repos/Zewo/PostgreSQL/hooks","issue_events_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/events{/number}","events_url":"https://api.github.com/repos/Zewo/PostgreSQL/events","assignees_url":"https://api.github.com/repos/Zewo/PostgreSQL/assignees{/user}","branches_url":"https://api.github.com/repos/Zewo/PostgreSQL/branches{/branch}","tags_url":"https://api.github.com/repos/Zewo/PostgreSQL/tags","blobs_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zewo/PostgreSQL/statuses/{sha}","languages_url":"https://api.github.com/repos/Zewo/PostgreSQL/languages","stargazers_url":"https://api.github.com/repos/Zewo/PostgreSQL/stargazers","contributors_url":"https://api.github.com/repos/Zewo/PostgreSQL/contributors","subscribers_url":"https://api.github.com/repos/Zewo/PostgreSQL/subscribers","subscription_url":"https://api.github.com/repos/Zewo/PostgreSQL/subscription","commits_url":"https://api.github.com/repos/Zewo/PostgreSQL/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zewo/PostgreSQL/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zewo/PostgreSQL/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zewo/PostgreSQL/contents/{+path}","compare_url":"https://api.github.com/repos/Zewo/PostgreSQL/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zewo/PostgreSQL/merges","archive_url":"https://api.github.com/repos/Zewo/PostgreSQL/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zewo/PostgreSQL/downloads","issues_url":"https://api.github.com/repos/Zewo/PostgreSQL/issues{/number}","pulls_url":"https://api.github.com/repos/Zewo/PostgreSQL/pulls{/number}","milestones_url":"https://api.github.com/repos/Zewo/PostgreSQL/milestones{/number}","notifications_url":"https://api.github.com/repos/Zewo/PostgreSQL/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zewo/PostgreSQL/labels{/name}","releases_url":"https://api.github.com/repos/Zewo/PostgreSQL/releases{/id}","deployments_url":"https://api.github.com/repos/Zewo/PostgreSQL/deployments","created_at":"2015-12-08T22:50:36Z","updated_at":"2016-12-11T16:20:29Z","pushed_at":"2016-12-01T09:48:26Z","git_url":"git://github.com/Zewo/PostgreSQL.git","ssh_url":"git@github.com:Zewo/PostgreSQL.git","clone_url":"https://github.com/Zewo/PostgreSQL.git","svn_url":"https://github.com/Zewo/PostgreSQL","homepage":"","size":353,"stargazers_count":91,"watchers_count":91,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":1,"forks":16,"open_issues":1,"watchers":91,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15"},"html":{"href":"https://github.com/Zewo/PostgreSQL/pull/15"},"issue":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/issues/15"},"comments":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/Zewo/PostgreSQL/statuses/eda562f896c510fb03d34845dbee323a081d1330"}}}}
{"actor":{"display_login":"Danappelxx"}}