thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer" <jensge...@hotmail.com>
Subject Re: Generic Data types design
Date Thu, 11 Apr 2013 20:24:52 GMT
Hi Avinash,

Short answer: if this structure suit your needs then it will be perfectly 
ok.

Long answer: At the end, the most important thing to consider is what you 
want to achieve and who will be the consumers of your service.

Your are about to design a part of an API, which purpose will be something 
that will be used by internal service clients, by external service clients, 
or even by both.

Especially if there will be external clients, I would think again, if the 
data layout and the layout of the service calls is really what you want or 
if you just did it this way because you wanted to solve the "API problem" as 
generically as possible to have it finished, off the table and then never 
think about it again. However, if your calls and your use cases require such 
a generic structure for some reason, then it is probably ok there.

I can't tell you that. I can only try to bring a personal view across, and 
in my case, I don't like overly generic structures. Especially in APIs, and 
especially when they are there without a good reason. From my maybe limited 
experience such APIs tend to be hard to use and more often than not come 
with a similar poor  and overly generic documentation. But of ourse there 
are also use cases where such data structures are the perfect solution one 
could think of.

So again, it depends on what you are doing.

HTH,
Jens



-----Urspr√ľngliche Nachricht----- 
From: Avinash Dongre
Sent: Thursday, April 11, 2013 8:04 PM
To: user@thrift.apache.org
Subject: Generic Data types design

Hi
I need to design a generic data type in Thrift IDL
Following is what I have come up with. I need some experts to review the
same.

/**
* wraper over various type declaration
*/
struct BoolType {
    1: required string name,
    2: required list<bool> val
}
struct ByteType {
    1: required string name,
    2: required list<byte> val
}
struct ShortType {
    1: required string name,
    2: required list<i16> val
}
struct IntType {
    1: required string name,
    2: required list<i32> val
}
struct LongType {
    1: required string name,
    2: required list<i64> val
}
struct DoubleType {
    1: required string name,
    2: required list<double> val
}
struct StringType {
    1: required string name,
    2: required list<string> val
}
struct BinaryType {
    1: required string name,
    2: required list<binary> val
}

union BasicType {
    1: BoolType        vBool,
    2: ByteType        vByte,
    3: IntType        vInt,
    4: LongType        vLong,
    5: DoubleType    vDouble,
    6: StringType    vString,
    7: BinaryType   vBinary
}

struct CompoundType {
    1: BoolType     vBool,
    2: ByteType        vByte,
    3: IntType        vInt,
    4: LongType        vLong,
    5: DoubleType    vDouble,
    6: StringType    vString,
    7: BinaryType   vBinary
}

union TObject {
    1: BasicType    vBasicType,
    2: CompoundType vCompoundType
}

TObject is something which I want to use in my Service API

Thanks
Avinash 


Mime
View raw message