thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Craig <bencr...@apache.org>
Subject Re: Generate .thrift file based on example .json file?
Date Fri, 04 Oct 2013 15:09:42 GMT
> From: Andrew Pennebaker <apennebaker@42six.com>
> To: Thrift Users <user@thrift.apache.org>, 
> Date: 10/04/2013 09:54 AM
> Subject: Re: Generate .thrift file based on example .json file?
> 
> That's good when you're in control of a service, but what about 
interacting
> with someone *else's* XML service? You can't always expect them to adopt
> Thrift.

If you want to interact with a non-Thrift service, you will need to author 
a new TProtocol class and / or a new code generator.

Here's some extra information on why that is so...

Suppose you have the following method in a .thrift service:
  i32 Janky(1: i32 arg);

That will generate code similar to the following (with variations 
depending on your language):
writeStructBegin("Srv_Janky_args");

writeFieldBegin("arg", T_I32, 1);
writeI32(arg);
writeFieldEnd();

writeFieldStop();
writeStructEnd();

The entire world doesn't set up their wire format in such a way.  Maybe 
they have some embedded sizes, or maybe they identify their messages with 
a GUID instead of a string.  Maybe they send data little endian instead of 
big endian.  Some of these problems can be addressed with a new TProtocol 
class, but other problems would need different code generation that 
doesn't follow the abstract Thrift protocol approach.

Basically, interoperating with an existing service isn't a problem that 
Thrift is trying to solve.

Mime
View raw message