diff --git a/src/http_server.cpp b/src/http_server.cpp index ad7ad04..73d0ebe 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -288,8 +288,13 @@ void HttpServer::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 { - duckdb::Connection con{*db}; if (WasCatalogUpdated(*db, con, last_state)) { SendCatalogChangedEvent(); } @@ -304,10 +309,10 @@ void HttpServer::Watch() { std::cerr << "Will now terminate." << std::endl; return; } + { std::unique_lock lock(watcher_mutex); - watcher_cv.wait_for(lock, - std::chrono::milliseconds(2000)); // TODO - configure + watcher_cv.wait_for(lock, std::chrono::milliseconds(polling_interval)); } } } diff --git a/src/ui_extension.cpp b/src/ui_extension.cpp index da2e0d7..568899e 100644 --- a/src/ui_extension.cpp +++ b/src/ui_extension.cpp @@ -86,6 +86,14 @@ static void LoadInternal(DatabaseInstance &instance) { 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_server", StartUIServerFunction); RESISTER_TF("stop_ui_server", StopUIServerFunction);