The way I usually handle this is by making the method return a custom struct with optional fields for each type that might be returned. This works if you know all of the types you *could* return from the method, but not if you might return anything. Thrift doesn't (yet) support a variant type that could contain any data type. As you pointed out, it could be challenging to do in some languages, but that doesn't mean it's not worth investigating.

-Bryan

On Feb 13, 2009, at 9:40 AM, Ali Al-Shabibi wrote:

Hello,

I am trying to port one of my services to Thrift, which by the way I think is a fantastic tool.

The service interface advertises a generic return type for some functions. This is because, a priori, the server does not know what datatype the incoming the request will generate

So, is it possible to define structs or lists which can contain generic types? If not, how hard would it be to implement this? I assume this would break support for some languages that do not support generic typing.

Thanks for your help,


--
Ali Al-Shabibi
Doctoral Student
PH-ATD
CERN - European Organization for Nuclear Research
Office: 513 R-018
[email protected]
Tel :   +41 22 767 86 46

Reply via email to