通用数据类型设计在thrift IDL中

时间:2013-04-11 19:23:00

标签: thrift

我需要在Thrift 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

中使用的内容

1 个答案:

答案 0 :(得分:-1)

与邮件列表上的答案相同:

  1. 所提供的信息不足以进行有意义的审核过度
  2. 通用数据结构是糟糕的API设计的良好指标。