{"action":"created","comment":{"url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/comments/53246511","id":53246511,"diff_hunk":"@@ -20,72 +20,137 @@\n \n 'use strict';\n \n-var Context = require('./context');\n-var Template = require('./template');\n-var Local = require('./local');\n-var Remote = require('./remote');\n var errors = require('./errors');\n \n var EMPTY_OBJECT = {};\n var EMPTY_ARRAY = [];\n \n-/* eslint-disable max-statements */\n+module.exports = RPC;\n \n-// TODO submit traces\n-// TODO ttlms queue\n-// TODO log incoming and outgoing requests and responses\n-// ... extendLogInfo via encoding, transport, connection\n-// TODO emit stats for incoming and outgoing requests and responses\n-\n-module.exports = Rpc;\n-\n-function Rpc(args) {\n+function RPC(args) {\n     this.service = args.service;\n     this.inbounds = args.inbounds || EMPTY_ARRAY;\n     this.outbounds = args.outbounds || EMPTY_OBJECT;\n+    this.dispatcher = args.dispatcher;\n     this.timers = args.timers;\n     this.logger = args.logger;\n-    this.local = new Local({rpc: this, timers: this.timers, logger: this.logger});\n-    this.remote = new Remote({handlers: this.outbounds, timers: this.timers, logger: this.logger});\n-}\n-\n-Rpc.prototype.httpCallerHeader = 'YARPC-Source';\n-Rpc.prototype.httpServiceHeader = 'YARPC-Service';\n-Rpc.prototype.httpProcedureHeader = 'YARPC-Procedure';\n-Rpc.prototype.httpEncodingHeader = 'YARPC-Encoding';\n-Rpc.prototype.httpTTLmsHeader = 'YARPC-TTLms';\n-\n-Rpc.prototype.inject = function inject(deps) {\n-    this.timers = deps.timers;\n-    this.logger = deps.logger;\n-\n-    // istanbul ignore if\n-    if (!this.timers) {\n-        throw new Error('YARPC requires timers dependency');\n-    }\n \n-    // istanbul ignore if\n-    if (!this.logger) {\n-        throw new Error('YARPC requires logger dependency');\n+    // istanbul ignore else\n+    if (this.dispatcher) {\n+        this.dispatcher.inject(this);\n+    } else if (this.inbounds.length > 0) {\n+        throw new Error('RPC requires a dispatcher for incoming requests');\n     }\n \n-    this.local.inject(deps);\n-    this.remote.inject(deps);\n-\n     for (var i = 0; i < this.inbounds.length; i++) {\n         var inbound = this.inbounds[i];\n-        inbound.inject(deps);\n+        inbound.inject(this);\n     }\n \n     var names = Object.keys(this.outbounds);\n     for (var i = 0; i < names.length; i++) {\n         var name = names[i];\n         var outbound = this.outbounds[name];\n-        outbound.inject(deps);\n+        outbound.inject(this);\n+    }\n+}\n+\n+RPC.prototype.httpCallerHeader = 'YARPC-Caller';","path":"rpc.js","position":79,"original_position":79,"commit_id":"1d649cdec48eb1d075854a3c6f5e378e37fc432e","original_commit_id":"e40ae69fac13c5f1267427e5aca81306ae2cbcf0","user":{"login":"kriskowal","id":60294,"avatar_url":"https://avatars.githubusercontent.com/u/60294?v=3","gravatar_id":"","url":"https://api.github.com/users/kriskowal","html_url":"https://github.com/kriskowal","followers_url":"https://api.github.com/users/kriskowal/followers","following_url":"https://api.github.com/users/kriskowal/following{/other_user}","gists_url":"https://api.github.com/users/kriskowal/gists{/gist_id}","starred_url":"https://api.github.com/users/kriskowal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kriskowal/subscriptions","organizations_url":"https://api.github.com/users/kriskowal/orgs","repos_url":"https://api.github.com/users/kriskowal/repos","events_url":"https://api.github.com/users/kriskowal/events{/privacy}","received_events_url":"https://api.github.com/users/kriskowal/received_events","type":"User","site_admin":false},"body":"coming right up.","created_at":"2016-02-17T23:01:36Z","updated_at":"2016-02-17T23:01:36Z","html_url":"https://github.com/yarpc/yarpc-node/pull/15#discussion_r53246511","pull_request_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/comments/53246511"},"html":{"href":"https://github.com/yarpc/yarpc-node/pull/15#discussion_r53246511"},"pull_request":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15","id":59614590,"html_url":"https://github.com/yarpc/yarpc-node/pull/15","diff_url":"https://github.com/yarpc/yarpc-node/pull/15.diff","patch_url":"https://github.com/yarpc/yarpc-node/pull/15.patch","issue_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/15","number":15,"state":"open","locked":false,"title":"Rewrite","user":{"login":"kriskowal","id":60294,"avatar_url":"https://avatars.githubusercontent.com/u/60294?v=3","gravatar_id":"","url":"https://api.github.com/users/kriskowal","html_url":"https://github.com/kriskowal","followers_url":"https://api.github.com/users/kriskowal/followers","following_url":"https://api.github.com/users/kriskowal/following{/other_user}","gists_url":"https://api.github.com/users/kriskowal/gists{/gist_id}","starred_url":"https://api.github.com/users/kriskowal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kriskowal/subscriptions","organizations_url":"https://api.github.com/users/kriskowal/orgs","repos_url":"https://api.github.com/users/kriskowal/repos","events_url":"https://api.github.com/users/kriskowal/events{/privacy}","received_events_url":"https://api.github.com/users/kriskowal/received_events","type":"User","site_admin":false},"body":"This is a complete rewrite, cannibalized from the prior version.\r\n\r\nIt supports raw, json, and thrift encodings.\r\n\r\nTo facilitate this, each of the layers provides onRequest/onResponse style hooks and the transport layer drives the life of the request.\r\n\r\nI’ve replaced the \"template\" function with one that is just called \"remote\", which returns a plain function with the same interface as the function accepted by register.\r\n\r\nI’ve added back the {service, procedure} dispatcher for inbound requests. I expect that we will write other \"handlers\", so I made a subdirectory in the spirit of encodings and transports.\r\n\r\nI re-separated request and context.\r\n\r\nI think I’ve nailed the error messages and type names.\r\n\r\nI provided example clients and servers for all three encodings, and a scaffold that drives each of these cases as part of the test suite. I also provided some curl commands that work against the example server. Just running these produces 80% code coverage. The tests mostly exercise error cases.","created_at":"2016-02-17T09:11:44Z","updated_at":"2016-02-17T23:01:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6930642e9e154ebfcbc431fd15c7c345cf304c7f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15/commits","review_comments_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15/comments","review_comment_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/15/comments","statuses_url":"https://api.github.com/repos/yarpc/yarpc-node/statuses/1d649cdec48eb1d075854a3c6f5e378e37fc432e","head":{"label":"yarpc:rewrite","ref":"rewrite","sha":"1d649cdec48eb1d075854a3c6f5e378e37fc432e","user":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"repo":{"id":50390070,"name":"yarpc-node","full_name":"yarpc/yarpc-node","owner":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yarpc/yarpc-node","description":"YARPC for Node.js","fork":false,"url":"https://api.github.com/repos/yarpc/yarpc-node","forks_url":"https://api.github.com/repos/yarpc/yarpc-node/forks","keys_url":"https://api.github.com/repos/yarpc/yarpc-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yarpc/yarpc-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yarpc/yarpc-node/teams","hooks_url":"https://api.github.com/repos/yarpc/yarpc-node/hooks","issue_events_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/events{/number}","events_url":"https://api.github.com/repos/yarpc/yarpc-node/events","assignees_url":"https://api.github.com/repos/yarpc/yarpc-node/assignees{/user}","branches_url":"https://api.github.com/repos/yarpc/yarpc-node/branches{/branch}","tags_url":"https://api.github.com/repos/yarpc/yarpc-node/tags","blobs_url":"https://api.github.com/repos/yarpc/yarpc-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yarpc/yarpc-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yarpc/yarpc-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/yarpc/yarpc-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yarpc/yarpc-node/statuses/{sha}","languages_url":"https://api.github.com/repos/yarpc/yarpc-node/languages","stargazers_url":"https://api.github.com/repos/yarpc/yarpc-node/stargazers","contributors_url":"https://api.github.com/repos/yarpc/yarpc-node/contributors","subscribers_url":"https://api.github.com/repos/yarpc/yarpc-node/subscribers","subscription_url":"https://api.github.com/repos/yarpc/yarpc-node/subscription","commits_url":"https://api.github.com/repos/yarpc/yarpc-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/yarpc/yarpc-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/yarpc/yarpc-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/yarpc/yarpc-node/contents/{+path}","compare_url":"https://api.github.com/repos/yarpc/yarpc-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yarpc/yarpc-node/merges","archive_url":"https://api.github.com/repos/yarpc/yarpc-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yarpc/yarpc-node/downloads","issues_url":"https://api.github.com/repos/yarpc/yarpc-node/issues{/number}","pulls_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls{/number}","milestones_url":"https://api.github.com/repos/yarpc/yarpc-node/milestones{/number}","notifications_url":"https://api.github.com/repos/yarpc/yarpc-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yarpc/yarpc-node/labels{/name}","releases_url":"https://api.github.com/repos/yarpc/yarpc-node/releases{/id}","deployments_url":"https://api.github.com/repos/yarpc/yarpc-node/deployments","created_at":"2016-01-26T00:02:57Z","updated_at":"2016-01-28T15:24:24Z","pushed_at":"2016-02-17T22:37:05Z","git_url":"git://github.com/yarpc/yarpc-node.git","ssh_url":"git@github.com:yarpc/yarpc-node.git","clone_url":"https://github.com/yarpc/yarpc-node.git","svn_url":"https://github.com/yarpc/yarpc-node","homepage":"","size":75,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"yarpc:master","ref":"master","sha":"8213a8a89512ddf6be70d5099dc3903a89262e11","user":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"repo":{"id":50390070,"name":"yarpc-node","full_name":"yarpc/yarpc-node","owner":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yarpc/yarpc-node","description":"YARPC for Node.js","fork":false,"url":"https://api.github.com/repos/yarpc/yarpc-node","forks_url":"https://api.github.com/repos/yarpc/yarpc-node/forks","keys_url":"https://api.github.com/repos/yarpc/yarpc-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yarpc/yarpc-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yarpc/yarpc-node/teams","hooks_url":"https://api.github.com/repos/yarpc/yarpc-node/hooks","issue_events_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/events{/number}","events_url":"https://api.github.com/repos/yarpc/yarpc-node/events","assignees_url":"https://api.github.com/repos/yarpc/yarpc-node/assignees{/user}","branches_url":"https://api.github.com/repos/yarpc/yarpc-node/branches{/branch}","tags_url":"https://api.github.com/repos/yarpc/yarpc-node/tags","blobs_url":"https://api.github.com/repos/yarpc/yarpc-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yarpc/yarpc-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yarpc/yarpc-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/yarpc/yarpc-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yarpc/yarpc-node/statuses/{sha}","languages_url":"https://api.github.com/repos/yarpc/yarpc-node/languages","stargazers_url":"https://api.github.com/repos/yarpc/yarpc-node/stargazers","contributors_url":"https://api.github.com/repos/yarpc/yarpc-node/contributors","subscribers_url":"https://api.github.com/repos/yarpc/yarpc-node/subscribers","subscription_url":"https://api.github.com/repos/yarpc/yarpc-node/subscription","commits_url":"https://api.github.com/repos/yarpc/yarpc-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/yarpc/yarpc-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/yarpc/yarpc-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/yarpc/yarpc-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/yarpc/yarpc-node/contents/{+path}","compare_url":"https://api.github.com/repos/yarpc/yarpc-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yarpc/yarpc-node/merges","archive_url":"https://api.github.com/repos/yarpc/yarpc-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yarpc/yarpc-node/downloads","issues_url":"https://api.github.com/repos/yarpc/yarpc-node/issues{/number}","pulls_url":"https://api.github.com/repos/yarpc/yarpc-node/pulls{/number}","milestones_url":"https://api.github.com/repos/yarpc/yarpc-node/milestones{/number}","notifications_url":"https://api.github.com/repos/yarpc/yarpc-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yarpc/yarpc-node/labels{/name}","releases_url":"https://api.github.com/repos/yarpc/yarpc-node/releases{/id}","deployments_url":"https://api.github.com/repos/yarpc/yarpc-node/deployments","created_at":"2016-01-26T00:02:57Z","updated_at":"2016-01-28T15:24:24Z","pushed_at":"2016-02-17T22:37:05Z","git_url":"git://github.com/yarpc/yarpc-node.git","ssh_url":"git@github.com:yarpc/yarpc-node.git","clone_url":"https://github.com/yarpc/yarpc-node.git","svn_url":"https://github.com/yarpc/yarpc-node","homepage":"","size":75,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15"},"html":{"href":"https://github.com/yarpc/yarpc-node/pull/15"},"issue":{"href":"https://api.github.com/repos/yarpc/yarpc-node/issues/15"},"comments":{"href":"https://api.github.com/repos/yarpc/yarpc-node/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yarpc/yarpc-node/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/yarpc/yarpc-node/statuses/1d649cdec48eb1d075854a3c6f5e378e37fc432e"}}}}