On Aug 11, 2011, at 12:19 PM, Brian Takita wrote:

> My company is creating a number of services that use thrift.
> 
> We are now wrestling with sharing structs across services.
> 
> Has anybody been able to share common structs from include files
> across namespaces?
> 
> One issue I see is the code generator can only support support one
> namespace. If a struct is included, it is put into the namespace of
> the generated thrift file. This means another generated thrift file
> with a different namespace will create a different class for that
> common struct.
> 
> e.g.
> 
> _user.thrift
> 
> struct User {
> }
> 
> user1.thrift
> 
> namespace rb User1
> include '_user.thrift'
> 
> user2.thrift
> 
> namespace rb User2
> include '_user.thrift'
> 
> Generating these files will cause User1::User and User2::User to be
> created, which would cause problems in the app code (if an app were to
> use user1.thrift and user2.thrift).
> 
> Has anybody gotten thrift to refer to the same User type across
> multiple namespaces?
> 
> One way around this is to use a single namespace across all of the
> thrift files in the entire company. Is that the recommended practice?
> 
> Thank you,
> Brian

Hi Brian,

Do you refer to User structures in user1.thrift and user2.thrift as _user.User?

I'm guessing you might get a local version if you don't do that (although I 
thought it would be an error).

We do this all over the place in C++/Java.

- Rush 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to