mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-29 08:34:47 +08:00
connection timeout seconds to milliseconds;
return exactly unpack error message.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user