Which is the corresponding Thrift type for:
- an Erlang tuple (I can imagine it's a struct)
- an Erlang atom (if any?)
Is there any documentation available with the direct mappings between the Erlang types and the Thrift IDL types?
Which is the corresponding Thrift type for:
Is there any documentation available with the direct mappings between the Erlang types and the Thrift IDL types?
Well, I'll try to answer myself :)
Apparently there is no direct translation of Erlang tuples in Thrift. What you can do is to include in your Erlang module the type definitions generated by Thrift and to write your Erlang code so that it uses the generated Erlang records as parameters and/or return values for your functions.
Erlang atoms must be translated into Thrift binaries (or eventually strings).
So, if you would like to have something like:
-spec cool_function() ->
{atom(), atom()}.
cool_function() ->
{foo, bar}
You will need to specify in your whatever.thrift file:
struct MyTuple {
1: binary first,
2: binary second
}
service myService {
MyTuple cool_function()
}
Plus, you need to write your Erlang function as:
[...]
-include("whatever_types.hrl").
[...]
-spec cool_function() ->
#myTuple{}.
cool_function() ->
#myTuple{
first = atom_to_binary(foo, utf8),
second = atom_to_binary(bar, utf8)
}.
Please, correct me if I'm wrong.