I have a enum definition in a file common.thrift :
enum LogLevel {
TRACE
DEBUG
INFO
WARN
ERROR
FATAL
}
Then there's a struct and a service method in an other file logGet.thrift (including common.thrift):
struct QueryOptions {
1: required common.LogEnvironment environment,
2: required list<common.LogLevel> levels, //it's about this list containing the enum value defined in common.thrift
}
service LogGet {
ResultList simpleGet(1: QueryOptions options);
}
The following generated Go method is where things go wrong (I believe). The method is supposed to read the TList values from the input protocol and push the values to QueryOptions.levels TList
Initially, the method doesn't work. It inserts a zero value (0) for each item that is pushed in the TList.
I found out that it wasn't working because the (TList).Push method verified that the given item has the right type. If not it inserts the zero value for the proper type.
This is done by TType.CoerceData() I believe.. Not sure....
Also, it seems the TList is created for I32 type. So apparently the mismatch between the types common.LogLevel and I32 makes Push() insert zero values.
So I edited the method to work. I commented out the 2 lines that where wrong, and added a line to do the push properly (using the "raw" I32 value).
I have a enum definition in a file common.thrift :
Then there's a struct and a service method in an other file logGet.thrift (including common.thrift):
The following generated Go method is where things go wrong (I believe). The method is supposed to read the TList values from the input protocol and push the values to QueryOptions.levels TList Initially, the method doesn't work. It inserts a zero value (0) for each item that is pushed in the TList. I found out that it wasn't working because the (TList).Push method verified that the given item has the right type. If not it inserts the zero value for the proper type. This is done by TType.CoerceData() I believe.. Not sure.... Also, it seems the TList is created for I32 type. So apparently the mismatch between the types common.LogLevel and I32 makes Push() insert zero values. So I edited the method to work. I commented out the 2 lines that where wrong, and added a line to do the push properly (using the "raw" I32 value).