Open HelloGrayson opened 8 years ago
@breerly
I'm going to split your suggestions into a list of atomic changes.
listen()
will default to zero and external IP if no arguments.TChannelThrift
should support a fileName instead of a thriftText string.codec.register()
should not need the endpoint name.codec.register()
should not need a context.fn(req, cb)
instead of fn(ctx, req, head, body, cb)
listen()
should default values.This is a great idea; we need to work out the defaults; maybe add autoListen()
. I do like the semantics of listen(port)
throws a "host required" exception.
:+1:
This can be done with a channel.register(serviceName, endpoint, handler)
or thriftCodec.register(channel, serviceName, endpoint, handler)
Whenever you register we do need a to know serviceName & endpoint. Having a default serviceName feels a bit iffy.
I don't think this is possible in JavaScript. We can't do function name introspection. Manually specifying the endpoint name seems reasonable to me.
We spoke about this when we designed the as thrift layer. We decided to make it mandatory and allow room for a registerWithoutContext()
method.
We really should encourage people to pass a context; i.e. a MyAppWorker instance for performance and consistency.
As mentioned above; we spoke about adding a registerWithoutContext()
When we designed the AsThrift layer we decided to have inreq, head, body
instead of create a ThriftInRequest
class. This was an optimization to avoid creating extra objects. Mutating the inreq
is definitely a not cool thing.
At this point I think we could benefit from a ThriftInRequest
.
Going through the workshop today was really eye-opening.
I feel like there is alot of room for improvement on the Node TChannel API. Mainly, we need to tune the API for the 99% case, while still allowing the 1% case.
Before:
After:
These aren't literal suggestions, but I'm just trying to illustrate what an API might look like that is minimal and does what 99% of people want without too much machinery and configuration.
cc @blampe @Raynos @prashantv @jcorbin