uber / tchannel

network multiplexing and framing protocol for RPC
MIT License
1.15k stars 129 forks source link

TChannel Node: Implement `getThriftCodec` on HyperbahnClient #1337

Open Raynos opened 9 years ago

Raynos commented 9 years ago
var tchannelThrift = hyperbahnClient.getThriftCodec({
    serviceName: 'steve'
    thriftFile: path.join(__dirname, 'thrift', 'steve.thrift'),
    timeout: 500 /* optional better default timeout for steve */
});

The idea is to hide the sub channel behind the thrift codec interface so that people dont have to know about sub channels.

This allows application developers to make requests like:

tchannelThrift.request({
    parent: inReq /* noParent: true */
}).send('Steve::doSomething', null, {
    /* body arguments */
}, function onResponse(err, response) {
    /* handle response */
});
Raynos commented 9 years ago

cc @jcorbin @rf @kriskowal ^

cc @Jeloi for the initial idea :)

jcorbin commented 9 years ago

sgtm

rf commented 9 years ago

I like it, but how about getThriftService? codec is really generic

kriskowal commented 9 years ago

Maybe getThriftChannel. What you’re getting has the shape of a channel. Code/Decode is the same as Read/Write and you’re not getting a ThriftRW.

Is this the best way to hide sub-channels? Should we hide sub-channels? The way to hide sub-channels is to present SubChannel as the Channel constructor folks use, which in turn constructs the topChannel on your behalf.

Raynos commented 9 years ago

This suggestion is not really about "hiding sub channels". The sub channel implementation detail is just hidden from the user with this method.

This method is all about simplifying the step from "I have a hyperbahn client" to "I make a thrift RPC call".