Make polling interval configurable

This commit is contained in:
Yves
2025-02-21 11:44:35 +01:00
parent 0b1a017c2e
commit ae104f697a
2 changed files with 16 additions and 3 deletions

View File

@@ -288,8 +288,13 @@ void HttpServer::Watch() {
break; // DB went away, nothing to watch break; // DB went away, nothing to watch
} }
duckdb::Connection con{*db};
auto polling_interval = GetPollingInterval(*con.context);
if (polling_interval == 0) {
return; // Disable watcher
}
try { try {
duckdb::Connection con{*db};
if (WasCatalogUpdated(*db, con, last_state)) { if (WasCatalogUpdated(*db, con, last_state)) {
SendCatalogChangedEvent(); SendCatalogChangedEvent();
} }
@@ -304,10 +309,10 @@ void HttpServer::Watch() {
std::cerr << "Will now terminate." << std::endl; std::cerr << "Will now terminate." << std::endl;
return; return;
} }
{ {
std::unique_lock<std::mutex> lock(watcher_mutex); std::unique_lock<std::mutex> lock(watcher_mutex);
watcher_cv.wait_for(lock, watcher_cv.wait_for(lock, std::chrono::milliseconds(polling_interval));
std::chrono::milliseconds(2000)); // TODO - configure
} }
} }
} }

View File

@@ -86,6 +86,14 @@ static void LoadInternal(DatabaseInstance &instance) {
LogicalType::VARCHAR, Value(def)); LogicalType::VARCHAR, Value(def));
} }
{
auto def = GetEnvOrDefaultInt(UI_POLLING_INTERVAL_SETTING_NAME, 284);
config.AddExtensionOption(
UI_POLLING_INTERVAL_SETTING_NAME,
"Period of time between UI polling requests (in ms)",
LogicalType::UINTEGER, Value::UINTEGER(def));
}
RESISTER_TF("start_ui", StartUIFunction); RESISTER_TF("start_ui", StartUIFunction);
RESISTER_TF("start_ui_server", StartUIServerFunction); RESISTER_TF("start_ui_server", StartUIServerFunction);
RESISTER_TF("stop_ui_server", StopUIServerFunction); RESISTER_TF("stop_ui_server", StopUIServerFunction);