Handling Apache Thrift list/map Return Types in C++
- by initzero
First off, I'll say I'm not the most competent C++ programmer, but I'm learning, and enjoying the power of Thrift.
I've implemented a Thrift Service with some basic functions that return void, i32, and list. I'm using a Python client controlled by a Django web app to make RPC calls and it works pretty well. The generated code is pretty straight forward, except for list returns:
namespace cpp Remote
enum N_PROTO {
N_TCP,
N_UDP,
N_ANY
}
service Rcon {
i32 ping()
i32 KillFlows()
i32 RestartDispatch()
i32 PrintActiveFlows()
i32 PrintActiveListeners(1:i32 proto)
list<string> ListAllFlows()
}
The generated signatures from Rcon.h:
int32_t ping();
int32_t KillFlows();
int32_t RestartDispatch();
int32_t PrintActiveFlows();
int32_t PrintActiveListeners(const int32_t proto);
int64_t ListenerBytesReceived(const int32_t id);
void ListAllFlows(std::vector<std::string> & _return);
As you see, the ListAllFlows() function generated takes a reference to a vector of strings. I guess I expect it to return a vector of strings as laid out in the .thrift description.
I'm wondering if I am meant to provide the function a vector of strings to modify and then Thrift will handle returning it to my client despite the function returning void.
I can find absolutely no resources or example usages of Thrift list< types in C++. Any guidance would be appreciated.