mnode_nng: reformat and print NNG_OPT_URL
sadly NNG_OPT_URL is empty for the inproc server socket. need to walk the list of listeners to query those?
This commit is contained in:
parent
24542b4a6d
commit
b0c6cddea6
1 changed files with 47 additions and 61 deletions
|
@ -18,10 +18,12 @@ void mnode_nng_error(const std::string &msg, int rv)
|
|||
|
||||
void log_socket_info(nng_socket s, const std::string &info_text)
|
||||
{
|
||||
auto url = socket_get_string_opt(s, NNG_OPT_URL);
|
||||
auto sockName = socket_get_string_opt(s, NNG_OPT_SOCKNAME);
|
||||
auto localAddress = socket_get_string_opt(s, NNG_OPT_LOCADDR);
|
||||
auto remoteAddress = socket_get_string_opt(s, NNG_OPT_REMADDR);
|
||||
|
||||
spdlog::info("{}: {}={}", info_text, NNG_OPT_URL, url);
|
||||
spdlog::info("{}: {}={}", info_text, NNG_OPT_SOCKNAME, sockName);
|
||||
spdlog::info("{}: {}={}", info_text, NNG_OPT_LOCADDR, localAddress);
|
||||
spdlog::info("{}: {}={}", info_text, NNG_OPT_REMADDR, remoteAddress);
|
||||
|
@ -77,11 +79,11 @@ const char *nng_stat_type_to_string(int nng_stat_type)
|
|||
}
|
||||
|
||||
template <typename Value>
|
||||
std::string format_stat(int type, const char *name, const char *desc, std::uint64_t ts, Value value, int unit)
|
||||
std::string format_stat(int type, const char *name, const char *desc, std::uint64_t ts, Value value,
|
||||
int unit)
|
||||
{
|
||||
return fmt::format("type={}, name={}, desc={}, ts={}, value={}, unit={}",
|
||||
nng::nng_stat_type_to_string(type),
|
||||
name, desc, ts, value,
|
||||
nng::nng_stat_type_to_string(type), name, desc, ts, value,
|
||||
nng::nng_stat_unit_to_string(unit));
|
||||
}
|
||||
|
||||
|
@ -90,9 +92,11 @@ std::string format_stat(nng_stat *stat)
|
|||
switch (nng_stat_type(stat))
|
||||
{
|
||||
case NNG_STAT_BOOLEAN:
|
||||
return format_stat(nng_stat_type(stat), nng_stat_name(stat), nng_stat_desc(stat), nng_stat_timestamp(stat), nng_stat_value(stat), nng_stat_unit(stat));
|
||||
return format_stat(nng_stat_type(stat), nng_stat_name(stat), nng_stat_desc(stat),
|
||||
nng_stat_timestamp(stat), nng_stat_value(stat), nng_stat_unit(stat));
|
||||
default:
|
||||
return format_stat(nng_stat_type(stat), nng_stat_name(stat), nng_stat_desc(stat), nng_stat_timestamp(stat), nng_stat_value(stat), nng_stat_unit(stat));
|
||||
return format_stat(nng_stat_type(stat), nng_stat_name(stat), nng_stat_desc(stat),
|
||||
nng_stat_timestamp(stat), nng_stat_value(stat), nng_stat_unit(stat));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,17 +112,20 @@ int send_message_retry(nng_socket socket, nng_msg *msg, retry_predicate rp, cons
|
|||
{
|
||||
if (res != NNG_ETIMEDOUT)
|
||||
{
|
||||
spdlog::warn("send_message_retry: {} - send failed: {} (msg={})", debugInfo, nng_strerror(res), fmt::ptr(msg));
|
||||
spdlog::warn("send_message_retry: {} - send failed: {} (msg={})", debugInfo,
|
||||
nng_strerror(res), fmt::ptr(msg));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (res == NNG_ETIMEDOUT)
|
||||
spdlog::trace("send_message_retry: {} - send timeout (msg={})", debugInfo, fmt::ptr(msg));
|
||||
spdlog::trace("send_message_retry: {} - send timeout (msg={})", debugInfo,
|
||||
fmt::ptr(msg));
|
||||
|
||||
if (!rp(res))
|
||||
return res;
|
||||
}
|
||||
} while (res == NNG_ETIMEDOUT);
|
||||
}
|
||||
while (res == NNG_ETIMEDOUT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -139,39 +146,18 @@ int send_empty_message(nng_socket socket, retry_predicate rp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
nng_socket make_pair_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_pair0_open, timeout);
|
||||
}
|
||||
nng_socket make_pair_socket(nng_duration timeout) { return make_socket(nng_pair0_open, timeout); }
|
||||
|
||||
nng_socket make_push_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_push0_open, timeout);
|
||||
}
|
||||
nng_socket make_push_socket(nng_duration timeout) { return make_socket(nng_push0_open, timeout); }
|
||||
|
||||
nng_socket make_pull_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_pull0_open, timeout);
|
||||
}
|
||||
nng_socket make_pull_socket(nng_duration timeout) { return make_socket(nng_pull0_open, timeout); }
|
||||
|
||||
nng_socket make_pub_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_pub0_open, timeout);
|
||||
}
|
||||
nng_socket make_pub_socket(nng_duration timeout) { return make_socket(nng_pub0_open, timeout); }
|
||||
|
||||
nng_socket make_sub_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_sub0_open, timeout);
|
||||
}
|
||||
nng_socket make_sub_socket(nng_duration timeout) { return make_socket(nng_sub0_open, timeout); }
|
||||
|
||||
nng_socket make_req_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_req0_open, timeout);
|
||||
}
|
||||
nng_socket make_req_socket(nng_duration timeout) { return make_socket(nng_req0_open, timeout); }
|
||||
|
||||
nng_socket make_rep_socket(nng_duration timeout)
|
||||
{
|
||||
return make_socket(nng_rep0_open, timeout);
|
||||
}
|
||||
nng_socket make_rep_socket(nng_duration timeout) { return make_socket(nng_rep0_open, timeout); }
|
||||
|
||||
}
|
||||
} // namespace mesytec::mnode::nng
|
||||
|
|
Loading…
Reference in a new issue