{"action":"created","comment":{"url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/comments/212531805","pull_request_review_id":149186665,"id":212531805,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjUzMTgwNQ==","diff_hunk":"@@ -72,12 +73,15 @@ public class HTTPHandler: ChannelInboundHandler {\n                 serverRequest.buffer!.byteBuffer.write(buffer: &buffer)\n             }\n         case .end(_):\n-            serverResponse = HTTPServerResponse(ctx: ctx, handler: self)\n+            serverResponse = HTTPServerResponse(channel: ctx.channel, handler: self)\n             //Make sure we use the latest delegate registered with the server\n-            if let delegate = server.delegate {\n-                Monitor.delegate?.started(request: serverRequest, response: serverResponse)\n-                delegate.handle(request: serverRequest, response: serverResponse)\n-            } //TODO: failure path\n+            DispatchQueue.global().async { [weak self] in\n+                guard let weakSelf = self else { fatalError(\"No HTTPHandler to proceed with the response.\") }\n+                if let delegate = weakSelf.server.delegate {\n+                    Monitor.delegate?.started(request: weakSelf.serverRequest, response: weakSelf.serverResponse)\n+                    delegate.handle(request: weakSelf.serverRequest, response: weakSelf.serverResponse)\n+                } //TODO: failure path","path":"Sources/KituraNet/HTTP/HTTPHandler.swift","position":null,"original_position":24,"commit_id":"8b4b8f9e18c294e1427e083e6f0f351dda9e7063","original_commit_id":"4088c15b519a366374b817601931b88ae0b40161","user":{"login":"pushkarnk","id":4761859,"node_id":"MDQ6VXNlcjQ3NjE4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4761859?v=4","gravatar_id":"","url":"https://api.github.com/users/pushkarnk","html_url":"https://github.com/pushkarnk","followers_url":"https://api.github.com/users/pushkarnk/followers","following_url":"https://api.github.com/users/pushkarnk/following{/other_user}","gists_url":"https://api.github.com/users/pushkarnk/gists{/gist_id}","starred_url":"https://api.github.com/users/pushkarnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushkarnk/subscriptions","organizations_url":"https://api.github.com/users/pushkarnk/orgs","repos_url":"https://api.github.com/users/pushkarnk/repos","events_url":"https://api.github.com/users/pushkarnk/events{/privacy}","received_events_url":"https://api.github.com/users/pushkarnk/received_events","type":"User","site_admin":false},"body":"Yeah, I think we can use the `HTTPDummyServerDelegate` here. We use that if no delegate is registered.","created_at":"2018-08-24T06:27:17Z","updated_at":"2018-08-24T06:27:18Z","html_url":"https://github.com/IBM-Swift/Kitura-NIO/pull/78#discussion_r212531805","pull_request_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/comments/212531805"},"html":{"href":"https://github.com/IBM-Swift/Kitura-NIO/pull/78#discussion_r212531805"},"pull_request":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78"}},"in_reply_to_id":212250547},"pull_request":{"url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78","id":210365671,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwMzY1Njcx","html_url":"https://github.com/IBM-Swift/Kitura-NIO/pull/78","diff_url":"https://github.com/IBM-Swift/Kitura-NIO/pull/78.diff","patch_url":"https://github.com/IBM-Swift/Kitura-NIO/pull/78.patch","issue_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/78","number":78,"state":"open","locked":false,"title":"Run the Kitura router on a DispatchQueue instead of an ELT","user":{"login":"pushkarnk","id":4761859,"node_id":"MDQ6VXNlcjQ3NjE4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4761859?v=4","gravatar_id":"","url":"https://api.github.com/users/pushkarnk","html_url":"https://github.com/pushkarnk","followers_url":"https://api.github.com/users/pushkarnk/followers","following_url":"https://api.github.com/users/pushkarnk/following{/other_user}","gists_url":"https://api.github.com/users/pushkarnk/gists{/gist_id}","starred_url":"https://api.github.com/users/pushkarnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushkarnk/subscriptions","organizations_url":"https://api.github.com/users/pushkarnk/orgs","repos_url":"https://api.github.com/users/pushkarnk/repos","events_url":"https://api.github.com/users/pushkarnk/events{/privacy}","received_events_url":"https://api.github.com/users/pushkarnk/received_events","type":"User","site_admin":false},"body":"Currently, the Kitura router that eventually invokes the endpoint handlers runs on the event loop threads. This is bad design primarily because the handlers may invoke blocking code which will end up blocking the event loop threads, reducing their availability to handle newer HTTP requests.\r\n\r\nThis pull request proposes moving the Kitura router invocation to a DispatchQueue, effectively freeing up the event loop thread which was scheduled to handle the related HTTP request. We move back to the event loop while writing the response - `HTTPServerResponse.end()`. Error handling (error responses) is done on the event loop. To write responses we use `Channel`s,  instead of `ChannelHandlerContext`s, owing to the thread-safety provided by them.","created_at":"2018-08-23T08:15:54Z","updated_at":"2018-08-24T06:27:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"30ef95703731d8793f8b6789a5387eb59da4a75f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78/commits","review_comments_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78/comments","review_comment_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/78/comments","statuses_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/statuses/8b4b8f9e18c294e1427e083e6f0f351dda9e7063","head":{"label":"pushkarnk:handler-on-dispatch","ref":"handler-on-dispatch","sha":"8b4b8f9e18c294e1427e083e6f0f351dda9e7063","user":{"login":"pushkarnk","id":4761859,"node_id":"MDQ6VXNlcjQ3NjE4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4761859?v=4","gravatar_id":"","url":"https://api.github.com/users/pushkarnk","html_url":"https://github.com/pushkarnk","followers_url":"https://api.github.com/users/pushkarnk/followers","following_url":"https://api.github.com/users/pushkarnk/following{/other_user}","gists_url":"https://api.github.com/users/pushkarnk/gists{/gist_id}","starred_url":"https://api.github.com/users/pushkarnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushkarnk/subscriptions","organizations_url":"https://api.github.com/users/pushkarnk/orgs","repos_url":"https://api.github.com/users/pushkarnk/repos","events_url":"https://api.github.com/users/pushkarnk/events{/privacy}","received_events_url":"https://api.github.com/users/pushkarnk/received_events","type":"User","site_admin":false},"repo":{"id":133504120,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1MDQxMjA=","name":"Kitura-NIO","full_name":"pushkarnk/Kitura-NIO","owner":{"login":"pushkarnk","id":4761859,"node_id":"MDQ6VXNlcjQ3NjE4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4761859?v=4","gravatar_id":"","url":"https://api.github.com/users/pushkarnk","html_url":"https://github.com/pushkarnk","followers_url":"https://api.github.com/users/pushkarnk/followers","following_url":"https://api.github.com/users/pushkarnk/following{/other_user}","gists_url":"https://api.github.com/users/pushkarnk/gists{/gist_id}","starred_url":"https://api.github.com/users/pushkarnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushkarnk/subscriptions","organizations_url":"https://api.github.com/users/pushkarnk/orgs","repos_url":"https://api.github.com/users/pushkarnk/repos","events_url":"https://api.github.com/users/pushkarnk/events{/privacy}","received_events_url":"https://api.github.com/users/pushkarnk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pushkarnk/Kitura-NIO","description":"A networking library for Kitura, based on SwiftNIO","fork":true,"url":"https://api.github.com/repos/pushkarnk/Kitura-NIO","forks_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/forks","keys_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/teams","hooks_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/hooks","issue_events_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/issues/events{/number}","events_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/events","assignees_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/assignees{/user}","branches_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/branches{/branch}","tags_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/tags","blobs_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/git/refs{/sha}","trees_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/statuses/{sha}","languages_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/languages","stargazers_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/stargazers","contributors_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/contributors","subscribers_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/subscribers","subscription_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/subscription","commits_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/commits{/sha}","git_commits_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/git/commits{/sha}","comments_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/comments{/number}","issue_comment_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/issues/comments{/number}","contents_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/contents/{+path}","compare_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/merges","archive_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/downloads","issues_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/issues{/number}","pulls_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/pulls{/number}","milestones_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/milestones{/number}","notifications_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/labels{/name}","releases_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/releases{/id}","deployments_url":"https://api.github.com/repos/pushkarnk/Kitura-NIO/deployments","created_at":"2018-05-15T11:08:01Z","updated_at":"2018-08-14T05:38:55Z","pushed_at":"2018-08-24T06:25:13Z","git_url":"git://github.com/pushkarnk/Kitura-NIO.git","ssh_url":"git@github.com:pushkarnk/Kitura-NIO.git","clone_url":"https://github.com/pushkarnk/Kitura-NIO.git","svn_url":"https://github.com/pushkarnk/Kitura-NIO","homepage":"","size":219,"stargazers_count":0,"watchers_count":0,"language":"Swift","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":{"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":"IBM-Swift:master","ref":"master","sha":"f7944c3bbcf7fdccd8787374bfbecf4b629f3975","user":{"login":"IBM-Swift","id":16882981,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODgyOTgx","avatar_url":"https://avatars3.githubusercontent.com/u/16882981?v=4","gravatar_id":"","url":"https://api.github.com/users/IBM-Swift","html_url":"https://github.com/IBM-Swift","followers_url":"https://api.github.com/users/IBM-Swift/followers","following_url":"https://api.github.com/users/IBM-Swift/following{/other_user}","gists_url":"https://api.github.com/users/IBM-Swift/gists{/gist_id}","starred_url":"https://api.github.com/users/IBM-Swift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IBM-Swift/subscriptions","organizations_url":"https://api.github.com/users/IBM-Swift/orgs","repos_url":"https://api.github.com/users/IBM-Swift/repos","events_url":"https://api.github.com/users/IBM-Swift/events{/privacy}","received_events_url":"https://api.github.com/users/IBM-Swift/received_events","type":"Organization","site_admin":false},"repo":{"id":133330351,"node_id":"MDEwOlJlcG9zaXRvcnkxMzMzMzAzNTE=","name":"Kitura-NIO","full_name":"IBM-Swift/Kitura-NIO","owner":{"login":"IBM-Swift","id":16882981,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODgyOTgx","avatar_url":"https://avatars3.githubusercontent.com/u/16882981?v=4","gravatar_id":"","url":"https://api.github.com/users/IBM-Swift","html_url":"https://github.com/IBM-Swift","followers_url":"https://api.github.com/users/IBM-Swift/followers","following_url":"https://api.github.com/users/IBM-Swift/following{/other_user}","gists_url":"https://api.github.com/users/IBM-Swift/gists{/gist_id}","starred_url":"https://api.github.com/users/IBM-Swift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IBM-Swift/subscriptions","organizations_url":"https://api.github.com/users/IBM-Swift/orgs","repos_url":"https://api.github.com/users/IBM-Swift/repos","events_url":"https://api.github.com/users/IBM-Swift/events{/privacy}","received_events_url":"https://api.github.com/users/IBM-Swift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IBM-Swift/Kitura-NIO","description":"A networking library for Kitura, based on SwiftNIO","fork":false,"url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO","forks_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/forks","keys_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/teams","hooks_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/hooks","issue_events_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/events{/number}","events_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/events","assignees_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/assignees{/user}","branches_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/branches{/branch}","tags_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/tags","blobs_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/git/refs{/sha}","trees_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/statuses/{sha}","languages_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/languages","stargazers_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/stargazers","contributors_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/contributors","subscribers_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/subscribers","subscription_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/subscription","commits_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/commits{/sha}","git_commits_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/git/commits{/sha}","comments_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/comments{/number}","issue_comment_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/comments{/number}","contents_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/contents/{+path}","compare_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/merges","archive_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/downloads","issues_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues{/number}","pulls_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls{/number}","milestones_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/milestones{/number}","notifications_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/labels{/name}","releases_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/releases{/id}","deployments_url":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/deployments","created_at":"2018-05-14T08:38:13Z","updated_at":"2018-08-23T16:48:56Z","pushed_at":"2018-08-24T06:25:15Z","git_url":"git://github.com/IBM-Swift/Kitura-NIO.git","ssh_url":"git@github.com:IBM-Swift/Kitura-NIO.git","clone_url":"https://github.com/IBM-Swift/Kitura-NIO.git","svn_url":"https://github.com/IBM-Swift/Kitura-NIO","homepage":"","size":214,"stargazers_count":17,"watchers_count":17,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":6,"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":4,"open_issues":6,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78"},"html":{"href":"https://github.com/IBM-Swift/Kitura-NIO/pull/78"},"issue":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/78"},"comments":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/IBM-Swift/Kitura-NIO/statuses/8b4b8f9e18c294e1427e083e6f0f351dda9e7063"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pushkarnk"}}