connection timeout seconds to milliseconds;

return exactly unpack error message.
This commit is contained in:
qicosmos
2019-06-01 09:48:05 +08:00
parent aa7a60be87
commit 6610d4e374
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -37,7 +37,9 @@ namespace rest_rpc {
template<typename T>
inline T as(string_view result) {
if (has_error(result)) {
throw std::logic_error("rpc error");
rpc_service::msgpack_codec codec;
auto tp = codec.unpack<std::tuple<int, std::string>>(result.data(), result.size());
throw std::logic_error(std::get<1>(tp));
}
return get_result<T>(result);
+2 -2
View File
@@ -118,7 +118,7 @@ namespace rest_rpc {
void async_reconnect(){
reset_socket();
async_connect();
std::this_thread::sleep_for(std::chrono::seconds(1));
std::this_thread::sleep_for(std::chrono::milliseconds(connect_timeout_));
}
bool connect(size_t timeout = 1) {
@@ -520,7 +520,7 @@ namespace rest_rpc {
std::string host_;
unsigned short port_ = 0;
size_t connect_timeout_ = 2;//s
size_t connect_timeout_ = 2000;//s
size_t wait_timeout_ = 2;//s
int reconnect_cnt_ = -1;
bool has_connected_ = false;