chore: refine guard structures and fix indentation

- Fixed indentation for TSDB methods in include/proxysql_admin.h.
- Refined PROXYSQLTSDB guard structure in lib/Admin_FlushVariables.cpp.
- Cleaned up indentation and redundant code in lib/ProxySQL_RESTAPI_Server.cpp.
- Ensured consistent formatting across modified files.
v3.0_31_base
Rene Cannao 1 month ago
parent 17225e8e23
commit 6b9918fdcc

@ -750,12 +750,12 @@ class ProxySQL_Admin {
void save_admin_variables_from_runtime() { flush_admin_variables___runtime_to_database(admindb, true, true, false); }
#ifdef PROXYSQLTSDB
// TSDB
void init_tsdb_variables();
void flush_tsdb_variables___runtime_to_database(SQLite3DB *db, bool replace, bool del, bool onlyifempty, bool runtime=false);
void flush_tsdb_variables___database_to_runtime(SQLite3DB *db, bool replace);
void load_tsdb_variables_to_runtime() { flush_tsdb_variables___database_to_runtime(admindb, true); }
void save_tsdb_variables_from_runtime() { flush_tsdb_variables___runtime_to_database(admindb, true, true, false); }
// TSDB
void init_tsdb_variables();
void flush_tsdb_variables___runtime_to_database(SQLite3DB *db, bool replace, bool del, bool onlyifempty, bool runtime=false);
void flush_tsdb_variables___database_to_runtime(SQLite3DB *db, bool replace);
void load_tsdb_variables_to_runtime() { flush_tsdb_variables___database_to_runtime(admindb, true); }
void save_tsdb_variables_from_runtime() { flush_tsdb_variables___runtime_to_database(admindb, true, true, false); }
#endif
void load_or_update_global_settings(SQLite3DB *);

@ -199,11 +199,9 @@ void ProxySQL_Admin::flush_GENERIC_variables__process__database_to_runtime(
#endif // PROXYSQLCLICKHOUSE
} else if (modname == "ldap") {
rc = GloMyLdapAuth->set_variable(r->fields[0],r->fields[1]);
} else if (modname == "tsdb") {
#ifdef PROXYSQLTSDB
} else if (modname == "tsdb") {
rc = GloProxyStats->set_variable(r->fields[0],r->fields[1]);
#else
rc = false;
#endif
}
const string v = string(r->fields[0]);
@ -223,11 +221,9 @@ void ProxySQL_Admin::flush_GENERIC_variables__process__database_to_runtime(
#endif // PROXYSQLCLICKHOUSE
} else if (modname == "ldap") {
val = GloMyLdapAuth->get_variable(r->fields[0]);
} else if (modname == "tsdb") {
#ifdef PROXYSQLTSDB
} else if (modname == "tsdb") {
val = GloProxyStats->get_variable(r->fields[0]);
#else
val = NULL;
#endif
}
char q[1000];

@ -416,7 +416,7 @@ public:
}
}
SQLite3_result *res = GloProxyStats->query_tsdb_metrics(metric, labels, from, to, agg);
SQLite3_result *res = GloProxyStats->query_tsdb_metrics(metric, labels, from, to, agg);
if (!res) {
j_resp = json::array();
} else {
@ -434,19 +434,19 @@ public:
}
delete res;
}
} else if (req_path == "/api/tsdb/status") {
if (!GloProxyStats) {
j_resp = json {{"error", "TSDB not initialized"}};
auto response = std::shared_ptr<http_response>(new string_response(j_resp.dump(), http::http_utils::http_internal_server_error));
add_headers(response);
return response;
}
ProxySQL_Statistics::tsdb_status_t status = GloProxyStats->get_tsdb_status();
j_resp["total_series"] = status.total_series;
j_resp["total_datapoints"] = status.total_datapoints;
j_resp["disk_size_bytes"] = status.disk_size_bytes;
j_resp["oldest_datapoint"] = status.oldest_datapoint;
j_resp["newest_datapoint"] = status.newest_datapoint;
} else if (req_path == "/api/tsdb/status") {
if (!GloProxyStats) {
j_resp = json {{"error", "TSDB not initialized"}};
auto response = std::shared_ptr<http_response>(new string_response(j_resp.dump(), http::http_utils::http_internal_server_error));
add_headers(response);
return response;
}
ProxySQL_Statistics::tsdb_status_t status = GloProxyStats->get_tsdb_status();
j_resp["total_series"] = status.total_series;
j_resp["total_datapoints"] = status.total_datapoints;
j_resp["disk_size_bytes"] = status.disk_size_bytes;
j_resp["oldest_datapoint"] = status.oldest_datapoint;
j_resp["newest_datapoint"] = status.newest_datapoint;
} else {
return std::shared_ptr<http_response>(new string_response("Not Found", http::http_utils::http_not_found));
}

Loading…
Cancel
Save