@@ -460,6 +460,38 @@ static HttpResponse process_query_rate_limit(MetaServiceImpl* service, brpc::Con
460460 return http_json_reply (MetaServiceCode::OK, " " , sb.GetString ());
461461}
462462
463+ static HttpResponse process_show_config (MetaServiceImpl*, brpc::Controller* cntl) {
464+ auto & uri = cntl->http_request ().uri ();
465+ std::string_view conf_name = http_query (uri, " conf_key" );
466+
467+ if (config::full_conf_map == nullptr ) {
468+ return http_json_reply (MetaServiceCode::UNDEFINED_ERR, " config map not initialized" );
469+ }
470+
471+ rapidjson::Document d;
472+ d.SetArray ();
473+
474+ for (auto & [name, field] : *config::Register::_s_field_map) {
475+ if (!conf_name.empty () && name != conf_name) {
476+ continue ;
477+ }
478+ auto it = config::full_conf_map->find (name);
479+ std::string value = (it != config::full_conf_map->end ()) ? it->second : " " ;
480+
481+ rapidjson::Value entry (rapidjson::kArrayType );
482+ entry.PushBack (rapidjson::Value (name.c_str (), d.GetAllocator ()), d.GetAllocator ());
483+ entry.PushBack (rapidjson::Value (field.type , d.GetAllocator ()), d.GetAllocator ());
484+ entry.PushBack (rapidjson::Value (value.c_str (), d.GetAllocator ()), d.GetAllocator ());
485+ entry.PushBack (rapidjson::Value (field.valmutable ), d.GetAllocator ());
486+ d.PushBack (entry, d.GetAllocator ());
487+ }
488+
489+ rapidjson::StringBuffer sb;
490+ rapidjson::PrettyWriter<rapidjson::StringBuffer> writer (sb);
491+ d.Accept (writer);
492+ return http_json_reply (MetaServiceCode::OK, " " , sb.GetString ());
493+ }
494+
463495static HttpResponse process_update_config (MetaServiceImpl* service, brpc::Controller* cntl) {
464496 const auto & uri = cntl->http_request ().uri ();
465497 bool persist = (http_query (uri, " persist" ) == " true" );
@@ -948,13 +980,15 @@ void MetaServiceImpl::http(::google::protobuf::RpcController* controller,
948980 {" adjust_rate_limit" , process_adjust_rate_limit},
949981 {" list_rate_limit" , process_query_rate_limit},
950982 {" update_config" , process_update_config},
983+ {" show_config" , process_show_config},
951984 {" v1/abort_txn" , process_abort_txn},
952985 {" v1/abort_tablet_job" , process_abort_tablet_job},
953986 {" v1/alter_ram_user" , process_alter_ram_user},
954987 {" v1/alter_iam" , process_alter_iam},
955988 {" v1/adjust_rate_limit" , process_adjust_rate_limit},
956989 {" v1/list_rate_limit" , process_query_rate_limit},
957990 {" v1/update_config" , process_update_config},
991+ {" v1/show_config" , process_show_config},
958992 };
959993
960994 auto * cntl = static_cast <brpc::Controller*>(controller);
0 commit comments