2013-04-11 37 views
1

我需要在Thrift IDL中設計通用數據類型 以下是我想到的。我需要一些專家來審查 相同。通用數據類型設計節儉IDL

/** 
* 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是我想在我服務的API使用這裏

回答

0

答案相同的郵件列表上的東西:

  1. 給出的信息是不夠的,過於做一個有意義的審查
  2. 通用數據結構是糟糕的API設計的良好指標。