我在oneway
我的 Thrift 函数定义之一中使用了修饰符:
...
oneway void secret_function(1: string x, 2: string y),
...
当通过 Thrift 生成相应的 Erlang 代码时,它被翻译成:
...
function_info('secret_function', reply_type) ->
oneway_void;
function_info('secret_function', exceptions) ->
{struct, []};
...
请注意oneway_void
那里的原子。
执行该secret_function
函数时,我收到以下错误:
=ERROR REPORT==== 2-Sep-2010::18:17:08 ===
oneway void secret_function threw error which must be ignored: {error,
function_clause,
[{thrift_protocol,
term_to_typeid,
[oneway_void]},
{thrift_protocol,
struct_write_loop,
3},
{thrift_protocol,
write,2},
{thrift_processor,
send_reply,
4},
{thrift_processor,
handle_function,
2},
{thrift_processor,
loop,1}]}
独立于用户代码中可能包含的错误,这里thrift_protocol:term_to_typeid/1
使用oneway_void
原子作为参数调用函数,这会导致函数子句。实际上,从代码中读取(thrift_protocol.erl):
...
term_to_typeid(void) -> ?tType_VOID;
term_to_typeid(bool) -> ?tType_BOOL;
term_to_typeid(byte) -> ?tType_BYTE;
term_to_typeid(double) -> ?tType_DOUBLE;
term_to_typeid(i16) -> ?tType_I16;
term_to_typeid(i32) -> ?tType_I32;
term_to_typeid(i64) -> ?tType_I64;
term_to_typeid(string) -> ?tType_STRING;
term_to_typeid({struct, _}) -> ?tType_STRUCT;
term_to_typeid({map, _, _}) -> ?tType_MAP;
term_to_typeid({set, _}) -> ?tType_SET;
term_to_typeid({list, _}) -> ?tType_LIST.
...
一个错误?还有其他解释吗?为什么oneway_void
要传递给那个函数?