3 ms·
I haven't used Thrift myself, but I just took a quick look at the docs. My initial reaction is that Thrift seems to be a bit heavier. WebRPC doesn't require any
by gk_brown 11y ago
I haven't used Thrift myself, but I just took a quick look at the docs. My initial reaction is that Thrift seems to be a bit heavier. WebRPC doesn't require any intermediate interface definitions and doesn't create language-specific client proxies. Method invocations are all dynamic (although you could easily wrap the invocation API in a statically typed adapter if you wanted to).
WebRPC isn't meant to be a replacement for REST - just an alternative. Sometimes it's simply more convenient to think in terms of "methods" than "resources".
- malandrew 11y agoIDLs are awesomely useful and you can build all sorts of things on that abstraction, especially if you have a parser that produces a standard AST (I wrote a PegJS parser that takes the Thrift IDLs and creates a plain old javascript object AST that can be used for things like: (1) writing dynamic serializers/deserializers for binary data (uber/thriftrw), (2) validators (not yet written, but will both lint as well as check for backwards compatibility when IDLs are updated); (3) bash autocompletion for an RPC api via a curl-like command (soon to land in uber/tcurl)) At Uber, we started with Apache Thrift, but found many things about it limited and broken with dubious code quality for some languages. Furthermore we had more ambitious ideas like application layer sharding (uber/ringpop) and service discovery and routing (uber/hyperbahn). We're still using the thrift protocols (uber/thriftrw) with our rpc library (uber/tchannel), but could have built on top of another IDL format like protobufs (v3). For those curious about the RPC interface, just check out: https://tchannel.readthedocs.org/en/latest/ https://tchannel.readthedocs.org/en/latest/ The interface supports all sorts of things This is all over TCP right now and designed for performance and service to service communication, but there is nothing preventing the addition of HTTP (via XHR or WebSockets) as a transport for allowing web apps to speak with tchannel services. I contributed to the Apache Thrift implementation that allows this (https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/web_server.js https://github.com/apache/thrift/blob/master/lib/nodejs/lib/...). The implementation for tchannel would be similar, but rely on XHR/WS in the browser and the `http` module instead of the `net` module in NodeJS on the server. It's trivial to write a proxy frontend that relays TJSONProtocol on the frontend to a Thrift binary protocol like TBinaryProtocol or TCompactProtocol. https://github.com/uber/hyperbahn https://github.com/uber/hyperbahn https://github.com/uber/tchannel https://github.com/uber/tchannel https://github.com/uber/ringpop-node https://github.com/uber/ringpop-node https://github.com/uber/ringpop-go https://github.com/uber/ringpop-go https://github.com/uber/idl https://github.com/uber/idl https://github.com/uber/tcurl https://github.com/uber/tcurl https://github.com/uber/tcap https://github.com/uber/tcap etc.
- gk_brown 11y agoThat sounds cool. WebRPC isn't meant to be an "everything to everyone" solution. It's main advantage is simplicity and low overhead. It allows you to quickly and easily build a service tier that is consumable by multiple clients. But if your requirements scale beyond what WebRPC provides, Thrift sounds like a great option.
- stephenr 11y agoThrift is such a broken mess I willingly opted instead to fork and update a Java project that exposes xml over http. Thrift must have been written by people who though SOAP was too easy to use and that developer lives should be made harder.
- malandrew 11y agoCompletely agree that the thrift stuff is a mess, which is why we only used the one interesting part, the IDL, for our system. These days, proto3 would be viable, but wasn't feature rich enough at the time for our needs when we were evaluating options.