{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/finagle/pulls/comments/80150708","id":80150708,"diff_hunk":"@@ -447,6 +473,43 @@ trait ThriftRichClient { self: Client[ThriftClientRequest, Array[Byte]] =>\n   def newMethodIface[ServiceIface, FutureIface](serviceIface: ServiceIface)(\n     implicit builder: MethodIfaceBuilder[ServiceIface, FutureIface]\n   ): FutureIface = builder.newMethodIface(serviceIface)\n+\n+  def multiplex[T](dest: Name, label: String)(build: MultiplexedThriftClient => T): T = {\n+    build(new MultiplexedThriftClient(dest, label))\n+  }\n+\n+  def multiplex[T](dest: String, label: String)(build: MultiplexedThriftClient => T): T = {\n+    multiplex(Resolver.eval(dest), label)(build)\n+  }\n+\n+  def multiplex[T](dest: String)(build: MultiplexedThriftClient => T): T = {\n+    val (n, l) = Resolver.evalLabeled(dest)\n+    multiplex(n, l)(build)\n+  }\n+\n+  class MultiplexedThriftClient(dest: Name, label: String) {\n+\n+    val service = newService(dest, label)","path":"finagle-thrift/src/main/scala/com/twitter/finagle/rich.scala","position":75,"original_position":75,"commit_id":"6695a5aa84908d3a0fe415bfdf2a63731bed6294","original_commit_id":"6695a5aa84908d3a0fe415bfdf2a63731bed6294","user":{"login":"kevinoliver","id":347229,"avatar_url":"https://avatars.githubusercontent.com/u/347229?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinoliver","html_url":"https://github.com/kevinoliver","followers_url":"https://api.github.com/users/kevinoliver/followers","following_url":"https://api.github.com/users/kevinoliver/following{/other_user}","gists_url":"https://api.github.com/users/kevinoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinoliver/subscriptions","organizations_url":"https://api.github.com/users/kevinoliver/orgs","repos_url":"https://api.github.com/users/kevinoliver/repos","events_url":"https://api.github.com/users/kevinoliver/events{/privacy}","received_events_url":"https://api.github.com/users/kevinoliver/received_events","type":"User","site_admin":false},"body":"can you reduce the visibility?","created_at":"2016-09-22T22:29:54Z","updated_at":"2016-09-22T22:41:27Z","html_url":"https://github.com/twitter/finagle/pull/545#discussion_r80150708","pull_request_url":"https://api.github.com/repos/twitter/finagle/pulls/545","_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments/80150708"},"html":{"href":"https://github.com/twitter/finagle/pull/545#discussion_r80150708"},"pull_request":{"href":"https://api.github.com/repos/twitter/finagle/pulls/545"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/finagle/pulls/545","id":82081380,"html_url":"https://github.com/twitter/finagle/pull/545","diff_url":"https://github.com/twitter/finagle/pull/545.diff","patch_url":"https://github.com/twitter/finagle/pull/545.patch","issue_url":"https://api.github.com/repos/twitter/finagle/issues/545","number":545,"state":"open","locked":false,"title":"serve multiple thrift ifaces","user":{"login":"thirstycrow","id":1327305,"avatar_url":"https://avatars.githubusercontent.com/u/1327305?v=3","gravatar_id":"","url":"https://api.github.com/users/thirstycrow","html_url":"https://github.com/thirstycrow","followers_url":"https://api.github.com/users/thirstycrow/followers","following_url":"https://api.github.com/users/thirstycrow/following{/other_user}","gists_url":"https://api.github.com/users/thirstycrow/gists{/gist_id}","starred_url":"https://api.github.com/users/thirstycrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thirstycrow/subscriptions","organizations_url":"https://api.github.com/users/thirstycrow/orgs","repos_url":"https://api.github.com/users/thirstycrow/repos","events_url":"https://api.github.com/users/thirstycrow/events{/privacy}","received_events_url":"https://api.github.com/users/thirstycrow/received_events","type":"User","site_admin":false},"body":"Problem\r\n\r\nFinagle uses an early version of libthrift, which does not support\r\nservice multiplexing.\r\n\r\nSolution\r\n\r\nSince 0.9.1, thrift added several classes to handle service multiplexing.\r\nOn the client side, TMultiplexedProtocol is used to decorate the\r\noriginal protocol, by prefixing a user specified service name as part of\r\nthe name of request message. Finagle uses the protocols from libthrift.\r\nAll we have to do is copying TMultiplexedProtocol and related classes\r\nfrom a newer version of libthrfit.\r\n\r\nOn the server side, TMultiplexedProcessor is used to inspect the\r\nbeginning of the incoming message names, and dispatch the message\r\nto an appropriate underlying processor. Finagle does not use\r\nprocessors, so we have to re-implement this.\r\n\r\nResult\r\n\r\nMultiple thrift services can be served through a single port, by passing\r\na map from service names to service implementations.\r\n```scala\r\nval serviceMap = Map(\r\n  \"echo\" -> new EchoService(),\r\n  \"extendedEcho\" -> new ExtendedEchoService()\r\n)\r\n\r\nval server = Thrift.server.serveIfaces(address, serviceMap)\r\n```\r\n\r\nMultiple Ifaces/ServiceIfaces can be created sharing the same underlying\r\nthrift client.\r\n```scala\r\nval client = Thrift.client.multiplex(address, \"client\") { client =>\r\n  new {\r\n    val echo = client.newIface[Echo.FutureIface](\"echo\")\r\n    val extendedEcho = client.newServiceIface[ExtendedEcho.ServiceIface](\"extendedEcho\")\r\n  }\r\n}\r\n\r\nclient.echo.echo(\"hello\")\r\nclient.extendedEcho.getStatus(ExtendedEcho.GetStatus.Args())\r\n```\r\n\r\n","created_at":"2016-08-20T15:27:56Z","updated_at":"2016-09-22T22:41:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7151b9af72d014f66e918b6212ec306f3f5c56d5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/twitter/finagle/pulls/545/commits","review_comments_url":"https://api.github.com/repos/twitter/finagle/pulls/545/comments","review_comment_url":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/finagle/issues/545/comments","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/6695a5aa84908d3a0fe415bfdf2a63731bed6294","head":{"label":"thirstycrow:thrift-service-multiplexing","ref":"thrift-service-multiplexing","sha":"6695a5aa84908d3a0fe415bfdf2a63731bed6294","user":{"login":"thirstycrow","id":1327305,"avatar_url":"https://avatars.githubusercontent.com/u/1327305?v=3","gravatar_id":"","url":"https://api.github.com/users/thirstycrow","html_url":"https://github.com/thirstycrow","followers_url":"https://api.github.com/users/thirstycrow/followers","following_url":"https://api.github.com/users/thirstycrow/following{/other_user}","gists_url":"https://api.github.com/users/thirstycrow/gists{/gist_id}","starred_url":"https://api.github.com/users/thirstycrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thirstycrow/subscriptions","organizations_url":"https://api.github.com/users/thirstycrow/orgs","repos_url":"https://api.github.com/users/thirstycrow/repos","events_url":"https://api.github.com/users/thirstycrow/events{/privacy}","received_events_url":"https://api.github.com/users/thirstycrow/received_events","type":"User","site_admin":false},"repo":{"id":21188045,"name":"finagle","full_name":"thirstycrow/finagle","owner":{"login":"thirstycrow","id":1327305,"avatar_url":"https://avatars.githubusercontent.com/u/1327305?v=3","gravatar_id":"","url":"https://api.github.com/users/thirstycrow","html_url":"https://github.com/thirstycrow","followers_url":"https://api.github.com/users/thirstycrow/followers","following_url":"https://api.github.com/users/thirstycrow/following{/other_user}","gists_url":"https://api.github.com/users/thirstycrow/gists{/gist_id}","starred_url":"https://api.github.com/users/thirstycrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thirstycrow/subscriptions","organizations_url":"https://api.github.com/users/thirstycrow/orgs","repos_url":"https://api.github.com/users/thirstycrow/repos","events_url":"https://api.github.com/users/thirstycrow/events{/privacy}","received_events_url":"https://api.github.com/users/thirstycrow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thirstycrow/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":true,"url":"https://api.github.com/repos/thirstycrow/finagle","forks_url":"https://api.github.com/repos/thirstycrow/finagle/forks","keys_url":"https://api.github.com/repos/thirstycrow/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thirstycrow/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thirstycrow/finagle/teams","hooks_url":"https://api.github.com/repos/thirstycrow/finagle/hooks","issue_events_url":"https://api.github.com/repos/thirstycrow/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/thirstycrow/finagle/events","assignees_url":"https://api.github.com/repos/thirstycrow/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/thirstycrow/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/thirstycrow/finagle/tags","blobs_url":"https://api.github.com/repos/thirstycrow/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thirstycrow/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thirstycrow/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/thirstycrow/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thirstycrow/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/thirstycrow/finagle/languages","stargazers_url":"https://api.github.com/repos/thirstycrow/finagle/stargazers","contributors_url":"https://api.github.com/repos/thirstycrow/finagle/contributors","subscribers_url":"https://api.github.com/repos/thirstycrow/finagle/subscribers","subscription_url":"https://api.github.com/repos/thirstycrow/finagle/subscription","commits_url":"https://api.github.com/repos/thirstycrow/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/thirstycrow/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/thirstycrow/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/thirstycrow/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/thirstycrow/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/thirstycrow/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thirstycrow/finagle/merges","archive_url":"https://api.github.com/repos/thirstycrow/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thirstycrow/finagle/downloads","issues_url":"https://api.github.com/repos/thirstycrow/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/thirstycrow/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/thirstycrow/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/thirstycrow/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thirstycrow/finagle/labels{/name}","releases_url":"https://api.github.com/repos/thirstycrow/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/thirstycrow/finagle/deployments","created_at":"2014-06-25T02:47:30Z","updated_at":"2015-07-02T15:32:00Z","pushed_at":"2016-08-20T14:57:24Z","git_url":"git://github.com/thirstycrow/finagle.git","ssh_url":"git@github.com:thirstycrow/finagle.git","clone_url":"https://github.com/thirstycrow/finagle.git","svn_url":"https://github.com/thirstycrow/finagle","homepage":"http://twitter.github.io/finagle","size":24552,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"twitter:develop","ref":"develop","sha":"ca4c237bf550cb0856e140d2b73b6168d325c089","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":1007362,"name":"finagle","full_name":"twitter/finagle","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":false,"url":"https://api.github.com/repos/twitter/finagle","forks_url":"https://api.github.com/repos/twitter/finagle/forks","keys_url":"https://api.github.com/repos/twitter/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/finagle/teams","hooks_url":"https://api.github.com/repos/twitter/finagle/hooks","issue_events_url":"https://api.github.com/repos/twitter/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/finagle/events","assignees_url":"https://api.github.com/repos/twitter/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/finagle/tags","blobs_url":"https://api.github.com/repos/twitter/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/finagle/languages","stargazers_url":"https://api.github.com/repos/twitter/finagle/stargazers","contributors_url":"https://api.github.com/repos/twitter/finagle/contributors","subscribers_url":"https://api.github.com/repos/twitter/finagle/subscribers","subscription_url":"https://api.github.com/repos/twitter/finagle/subscription","commits_url":"https://api.github.com/repos/twitter/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/finagle/merges","archive_url":"https://api.github.com/repos/twitter/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/finagle/downloads","issues_url":"https://api.github.com/repos/twitter/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/finagle/labels{/name}","releases_url":"https://api.github.com/repos/twitter/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/finagle/deployments","created_at":"2010-10-19T22:10:09Z","updated_at":"2016-09-22T22:08:28Z","pushed_at":"2016-09-22T19:56:42Z","git_url":"git://github.com/twitter/finagle.git","ssh_url":"git@github.com:twitter/finagle.git","clone_url":"https://github.com/twitter/finagle.git","svn_url":"https://github.com/twitter/finagle","homepage":"http://twitter.github.io/finagle","size":47861,"stargazers_count":5067,"watchers_count":5067,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":965,"mirror_url":null,"open_issues_count":33,"forks":965,"open_issues":33,"watchers":5067,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/545"},"html":{"href":"https://github.com/twitter/finagle/pull/545"},"issue":{"href":"https://api.github.com/repos/twitter/finagle/issues/545"},"comments":{"href":"https://api.github.com/repos/twitter/finagle/issues/545/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/finagle/pulls/545/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/finagle/pulls/545/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/finagle/statuses/6695a5aa84908d3a0fe415bfdf2a63731bed6294"}}}}
{"actor":{"display_login":"kevinoliver"}}