diff --git a/mgmt/rpc/jsonrpc/JsonRPCManager.cc b/mgmt/rpc/jsonrpc/JsonRPCManager.cc index 050f5a44302..fc3ce0b13da 100644 --- a/mgmt/rpc/jsonrpc/JsonRPCManager.cc +++ b/mgmt/rpc/jsonrpc/JsonRPCManager.cc @@ -26,6 +26,7 @@ #include #include +#include #include "json/YAMLCodec.h" namespace @@ -265,33 +266,33 @@ inline ts::Rv JsonRPCManager::Dispatcher::InternalHandler::invoke(specs::RPCRequestInfo const &request) const { ts::Rv ret; - std::visit(ts::meta::overloaded{[](std::monostate) -> void { /* no op */ }, - [&request](Notification const &handler) -> void { - // Notification handler call. Ignore response, there is no completion cv check in here basically - // because we do not deal with any response, the callee can just re-schedule the work if - // needed. We fire and forget. - handler.cb(request.params); - }, - [&ret, &request](Method const &handler) -> void { - // Regular Method Handler call, No cond variable check here, this should have not be created by - // a plugin. - ret = handler.cb(request.id, request.params); - }, - [&ret, &request](PluginMethod const &handler) -> void { - // We call the method handler, we'll lock and wait till the condition_variable - // gets set on the other side. The handler may return immediately with no response being set. - // cond var will give us green to proceed. - handler.cb(request.id, request.params); - std::unique_lock lock(g_rpcHandlingMutex); - g_rpcHandlingCompletion.wait(lock, []() { return g_rpcHandlerProcessingCompleted; }); - g_rpcHandlerProcessingCompleted = false; - // seems to be done, set the response. As the response data is a ts::Rv this will handle both, - // error and non error cases. - ret = g_rpcHandlerResponseData; - // clean up the shared data. - g_rpcHandlerResponseData.clear(); - lock.unlock(); - }}, + std::visit(swoc::meta::vary{[](std::monostate) -> void { /* no op */ }, + [&request](Notification const &handler) -> void { + // Notification handler call. Ignore response, there is no completion cv check in here basically + // because we do not deal with any response, the callee can just re-schedule the work if + // needed. We fire and forget. + handler.cb(request.params); + }, + [&ret, &request](Method const &handler) -> void { + // Regular Method Handler call, No cond variable check here, this should have not be created by + // a plugin. + ret = handler.cb(request.id, request.params); + }, + [&ret, &request](PluginMethod const &handler) -> void { + // We call the method handler, we'll lock and wait till the condition_variable + // gets set on the other side. The handler may return immediately with no response being set. + // cond var will give us green to proceed. + handler.cb(request.id, request.params); + std::unique_lock lock(g_rpcHandlingMutex); + g_rpcHandlingCompletion.wait(lock, []() { return g_rpcHandlerProcessingCompleted; }); + g_rpcHandlerProcessingCompleted = false; + // seems to be done, set the response. As the response data is a ts::Rv this will handle both, + // error and non error cases. + ret = g_rpcHandlerResponseData; + // clean up the shared data. + g_rpcHandlerResponseData.clear(); + lock.unlock(); + }}, this->_func); return ret; } @@ -330,7 +331,7 @@ JsonRPCManager::Dispatcher::get_service_descriptor(std::string_view const &, con { YAML::Node rpcService; std::lock_guard lock(_mutex); - // std::for_each(std::begin(_handlers), std::end(_handlers), [&rpcService](auto const &h) { + for (auto const &[name, handler] : _handlers) { YAML::Node method; method[RPC_SERVICE_NAME_KEY] = name; diff --git a/mgmt/rpc/jsonrpc/JsonRPCManager.h b/mgmt/rpc/jsonrpc/JsonRPCManager.h index 29727ce0285..24777fc6b7a 100644 --- a/mgmt/rpc/jsonrpc/JsonRPCManager.h +++ b/mgmt/rpc/jsonrpc/JsonRPCManager.h @@ -30,7 +30,6 @@ #include "tscore/Errata.h" #include "tscore/Diags.h" -#include "tscpp/util/ts_meta.h" #include "ts/apidefs.h" #include "Defs.h" diff --git a/src/traffic_ctl/CtrlPrinters.cc b/src/traffic_ctl/CtrlPrinters.cc index ba06b230df4..b75ff40e889 100644 --- a/src/traffic_ctl/CtrlPrinters.cc +++ b/src/traffic_ctl/CtrlPrinters.cc @@ -24,7 +24,7 @@ #include #include "jsonrpc/ctrl_yaml_codecs.h" -#include "tscpp/util/ts_meta.h" +#include #include #include #include @@ -248,7 +248,7 @@ RecordDescribePrinter::write_output(YAML::Node const &result) std::cout << swoc::bwprint(text, "{:16s}: {}\n", "Record Type ", rec_labelof(recordInfo.rclass)); std::cout << swoc::bwprint(text, "{:16s}: {}\n", "Data Type ", recordInfo.dataType); - std::visit(ts::meta::overloaded{ + std::visit(swoc::meta::vary{ [&](shared::rpc::RecordLookUpResponse::RecordParamInfo::ConfigMeta const &meta) { std::cout << swoc::bwprint(text, "{:16s}: {}\n", "Access Control ", rec_accessof(meta.accessType)); std::cout << swoc::bwprint(text, "{:16s}: {}\n", "Update Type ", rec_updateof(meta.updateType));