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