SON conn. pool
This commit is contained in:
parent
c4f3f37075
commit
75e6f9abd5
3 changed files with 17 additions and 5 deletions
|
|
@ -27,12 +27,9 @@ class rpc_connection {
|
|||
public:
|
||||
rpc_connection(std::string _url, std::string _user, std::string _password, bool _debug_rpc_calls);
|
||||
|
||||
protected:
|
||||
//static std::string retrieve_array_value_from_reply(std::string reply_str, std::string array_path, uint32_t idx);
|
||||
//static std::string retrieve_value_from_reply(std::string reply_str, std::string value_path);
|
||||
|
||||
public:
|
||||
std::string send_post_request(std::string method, std::string params, bool show_log);
|
||||
std::string get_url() const;
|
||||
|
||||
protected:
|
||||
|
||||
std::string url;
|
||||
|
|
@ -99,6 +96,11 @@ rpc_connection::rpc_connection(std::string _url, std::string _user, std::string
|
|||
}
|
||||
}
|
||||
|
||||
std::string rpc_connection::get_url() const
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
std::string rpc_client::retrieve_array_value_from_reply(std::string reply_str, std::string array_path, uint32_t idx) {
|
||||
if (reply_str.empty()) {
|
||||
wlog("RPC call ${function}, empty reply string", ("function", __FUNCTION__));
|
||||
|
|
@ -371,6 +373,11 @@ std::string rpc_client::send_post_request(rpc_connection &conn, std::string meth
|
|||
return conn.send_post_request(method, params, show_log);
|
||||
}
|
||||
|
||||
std::string rpc_client::get_connection_url(const rpc_connection &conn)
|
||||
{
|
||||
return conn.get_url();
|
||||
}
|
||||
|
||||
rpc_client::~rpc_client()
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ protected:
|
|||
static std::string retrieve_array_value_from_reply(std::string reply_str, std::string array_path, uint32_t idx);
|
||||
static std::string retrieve_value_from_reply(std::string reply_str, std::string value_path);
|
||||
|
||||
static std::string get_connection_url(const rpc_connection &conn);
|
||||
|
||||
private:
|
||||
std::vector<rpc_connection*> connections;
|
||||
int n_active_conn;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ std::string hive_rpc_client::get_last_irreversible_block_num() {
|
|||
}
|
||||
|
||||
uint64_t hive_rpc_client::ping(rpc_connection &conn) const {
|
||||
|
||||
ilog("!!!hive_rpc_client::ping() ${url}", ("url", get_connection_url(conn)));
|
||||
|
||||
const std::string reply = send_post_request(conn, "database_api.get_dynamic_global_properties", "", debug_rpc_calls);
|
||||
if (!reply.empty()) {
|
||||
std::stringstream ss(reply);
|
||||
|
|
|
|||
Loading…
Reference in a new issue