31 std::cout <<
"=== Config Watcher Example ===\n\n";
34 const std::string config_path =
"example_config.yaml";
36 std::ofstream f(config_path);
39 <<
" queue_type: adaptive\n"
44 <<
" metrics_interval: 30\n";
48 std::cout <<
"1. Creating config watcher for '" << config_path <<
"'...\n";
55 std::cout <<
"\n [Change detected]\n";
61 watcher.
on_error([](
const std::string& error)
62 { std::cerr <<
" [Config error] " << error <<
"\n"; });
65 std::cout <<
"\n2. Starting file watcher...\n";
66 auto start_result = watcher.
start();
67 if (start_result.is_ok())
69 std::cout <<
" Watcher running = " << (watcher.
is_running() ?
"true" :
"false") <<
"\n";
73 std::cout <<
" Watcher start skipped (platform may not support file watching in this "
78 std::cout <<
"\n3. Modifying config file...\n";
80 std::ofstream f(config_path);
83 <<
" queue_type: lock_free\n"
88 <<
" metrics_interval: 10\n";
92 std::this_thread::sleep_for(std::chrono::milliseconds(500));
95 std::cout <<
"\n4. Manual reload...\n";
96 auto reload_result = watcher.
reload();
97 std::cout <<
" Reload: " << (reload_result.is_ok() ?
"success" :
"skipped") <<
"\n";
100 std::cout <<
"\n5. Stopping watcher...\n";
102 std::cout <<
" Watcher running = " << (watcher.
is_running() ?
"true" :
"false") <<
"\n";
105 std::remove(config_path.c_str());
107 std::cout <<
"\nDone.\n";
Monitors configuration files for changes and supports hot-reload.
bool is_running() const
Check if the watcher is currently running.
VoidResult reload()
Manually trigger a configuration reload.
VoidResult start()
Start watching the configuration file for changes.
void on_change(change_callback callback)
Register a callback for configuration changes.
void stop()
Stop watching the configuration file.
void on_error(error_callback callback)
Register a callback for reload errors.
Configuration hot-reload support with file system watching.
size_t pool_size
Number of worker threads (default: hardware concurrency)
Root configuration structure for the unified system.
thread_config thread
Thread system configuration.
Unified configuration schema for the entire system.