{"action":"created","issue":{"url":"https://api.github.com/repos/uber/tchannel/issues/84","labels_url":"https://api.github.com/repos/uber/tchannel/issues/84/labels{/name}","comments_url":"https://api.github.com/repos/uber/tchannel/issues/84/comments","events_url":"https://api.github.com/repos/uber/tchannel/issues/84/events","html_url":"https://github.com/uber/tchannel/issues/84","id":59193695,"number":84,"title":"scope out an \"as\" handler api","user":{"login":"Raynos","id":479538,"avatar_url":"https://avatars.githubusercontent.com/u/479538?v=3","gravatar_id":"","url":"https://api.github.com/users/Raynos","html_url":"https://github.com/Raynos","followers_url":"https://api.github.com/users/Raynos/followers","following_url":"https://api.github.com/users/Raynos/following{/other_user}","gists_url":"https://api.github.com/users/Raynos/gists{/gist_id}","starred_url":"https://api.github.com/users/Raynos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Raynos/subscriptions","organizations_url":"https://api.github.com/users/Raynos/orgs","repos_url":"https://api.github.com/users/Raynos/repos","events_url":"https://api.github.com/users/Raynos/events{/privacy}","received_events_url":"https://api.github.com/users/Raynos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/uber/tchannel/labels/node","name":"node","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-27T05:47:36Z","updated_at":"2015-06-16T18:25:02Z","closed_at":"2015-06-16T18:25:02Z","body":"There was question about how to support as encoding & decoding.\r\n\r\nI take inspiration from leveldb interface ( https://github.com/rvagg/node-levelup#custom_encodings ).\r\n\r\nI think it would be nice to have.\r\n\r\n```js\r\ntchannel.asEncoding('json', {\r\n  encodeArg2: function (arg2) { return [err, buffer]; },\r\n  encodeArg3: function (arg3) { return [err, buffer]; },\r\n  decodeArg2: function (buffer) { return [err, arg2]; },\r\n  decodeArg3: function (buffer) { return [err, arg3]; }\r\n});\r\n```\r\n\r\nWhen decoding buffers into structured data, any error returned is considered a parsing error and is returned to the client.\r\n\r\nWhen encoding structured data into buffers, any error returned is considered an application error. I'm not really sure what to do about that yet. In the json encoder I currently send a server error to the client.\r\n\r\nWith this interface we can either allow people to configure encodings on a single tchannel instance or on the tchannel constructor, maybe both.\r\n\r\nI would favor configuring encodings on a single tchannel instance and would personally do so in the part of my application where I bootstrap."},"comment":{"url":"https://api.github.com/repos/uber/tchannel/issues/comments/112521047","html_url":"https://github.com/uber/tchannel/issues/84#issuecomment-112521047","issue_url":"https://api.github.com/repos/uber/tchannel/issues/84","id":112521047,"user":{"login":"Raynos","id":479538,"avatar_url":"https://avatars.githubusercontent.com/u/479538?v=3","gravatar_id":"","url":"https://api.github.com/users/Raynos","html_url":"https://github.com/Raynos","followers_url":"https://api.github.com/users/Raynos/followers","following_url":"https://api.github.com/users/Raynos/following{/other_user}","gists_url":"https://api.github.com/users/Raynos/gists{/gist_id}","starred_url":"https://api.github.com/users/Raynos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Raynos/subscriptions","organizations_url":"https://api.github.com/users/Raynos/orgs","repos_url":"https://api.github.com/users/Raynos/repos","events_url":"https://api.github.com/users/Raynos/events{/privacy}","received_events_url":"https://api.github.com/users/Raynos/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T18:25:02Z","updated_at":"2015-06-16T18:25:02Z","body":"The as handlers are fully implemented in master. This suggested interface is deprecated."}}