Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
kcenon::common::config Namespace Reference

Namespaces

namespace  cli_error_codes
 CLI parsing error codes.
 
namespace  config_error_codes
 Configuration loading error codes.
 
namespace  watcher_error_codes
 Error codes specific to config_watcher.
 

Classes

class  cli_config_parser
 Parses command-line arguments for configuration. More...
 
struct  cli_option
 Definition for a CLI option. More...
 
struct  cli_parse_result
 Result of CLI parsing. More...
 
class  CliConfigParser
 Simple command-line argument parser. More...
 
struct  config_change_event
 Information about a configuration change event. More...
 
struct  config_entry
 A single configuration entry. More...
 
class  config_loader
 Loads and validates unified configuration from various sources. More...
 
struct  config_snapshot
 Represents a configuration snapshot for version history. More...
 
class  config_watcher
 Monitors configuration files for changes and supports hot-reload. More...
 
struct  database_config
 Database system configuration. More...
 
struct  feature_flags
 Compile-time feature detection flags. More...
 
struct  field_metadata
 Configuration field metadata for validation and documentation. More...
 
class  IConfigLoader
 Interface for configuration loaders. More...
 
struct  logger_config
 Logging system configuration. More...
 
struct  monitoring_config
 Monitoring system configuration. More...
 
struct  network_config
 Network system configuration. More...
 
struct  parsed_args
 Parsed command-line arguments. More...
 
struct  pool_config
 Database connection pool configuration. More...
 
struct  thread_config
 Thread pool configuration. More...
 
struct  tls_config
 TLS/SSL configuration. More...
 
struct  tracing_config
 Distributed tracing configuration. More...
 
struct  unified_config
 Root configuration structure for the unified system. More...
 
struct  validation_issue
 Validation result for a configuration field. More...
 

Typedefs

using kcenon::common::config::config_value
 Configuration value type.
 

Functions

std::vector< field_metadataget_config_metadata ()
 Get metadata for all configuration fields.
 
bool is_hot_reloadable (const std::string &field_path)
 Check if a configuration field supports hot-reload.
 

Variables

constexpr const char * ENV_PREFIX = "UNIFIED_"
 Environment variable prefix for configuration overrides.
 

Typedef Documentation

◆ config_value

Initial value:
std::variant<
std::string,
int64_t,
double,
bool,
std::vector<std::string>,
std::map<std::string, std::string>
>

Configuration value type.

Definition at line 62 of file config.cppm.

Function Documentation

◆ get_config_metadata()

std::vector< field_metadata > kcenon::common::config::get_config_metadata ( )
inline

Get metadata for all configuration fields.

Returns
Vector of field metadata

Definition at line 283 of file unified_config.h.

283 {
284 return {
285 // Thread configuration
286 {"thread.pool_size", "Number of worker threads (0 for auto)", false,
287 "UNIFIED_THREAD_POOL_SIZE", {}},
288 {"thread.queue_type", "Task queue type", false,
289 "UNIFIED_THREAD_QUEUE_TYPE", {"mutex", "lockfree", "bounded"}},
290 {"thread.max_queue_size", "Maximum task queue size", false,
291 "UNIFIED_THREAD_MAX_QUEUE_SIZE", {}},
292
293 // Logger configuration
294 {"logger.level", "Log level", true,
295 "UNIFIED_LOGGER_LEVEL",
296 {"trace", "debug", "info", "warn", "error", "critical", "off"}},
297 {"logger.async", "Enable async logging", false,
298 "UNIFIED_LOGGER_ASYNC", {}},
299 {"logger.buffer_size", "Async buffer size", false,
300 "UNIFIED_LOGGER_BUFFER_SIZE", {}},
301 {"logger.file_path", "Log file path", true,
302 "UNIFIED_LOGGER_FILE_PATH", {}},
303
304 // Monitoring configuration
305 {"monitoring.enabled", "Enable monitoring", false,
306 "UNIFIED_MONITORING_ENABLED", {}},
307 {"monitoring.metrics_interval", "Metrics collection interval (ms)", true,
308 "UNIFIED_MONITORING_METRICS_INTERVAL_MS", {}},
309 {"monitoring.tracing.enabled", "Enable distributed tracing", false,
310 "UNIFIED_MONITORING_TRACING_ENABLED", {}},
311 {"monitoring.tracing.sampling_rate", "Trace sampling rate", true,
312 "UNIFIED_MONITORING_TRACING_SAMPLING_RATE", {}},
313
314 // Database configuration
315 {"database.backend", "Database backend type", false,
316 "UNIFIED_DATABASE_BACKEND",
317 {"postgresql", "mysql", "sqlite", "mongodb", "redis"}},
318 {"database.connection_string", "Database connection string", false,
319 "UNIFIED_DATABASE_CONNECTION_STRING", {}},
320 {"database.pool.min_size", "Minimum pool size", false,
321 "UNIFIED_DATABASE_POOL_MIN_SIZE", {}},
322 {"database.pool.max_size", "Maximum pool size", false,
323 "UNIFIED_DATABASE_POOL_MAX_SIZE", {}},
324
325 // Network configuration
326 {"network.tls.enabled", "Enable TLS", false,
327 "UNIFIED_NETWORK_TLS_ENABLED", {}},
328 {"network.tls.version", "TLS version", false,
329 "UNIFIED_NETWORK_TLS_VERSION", {"1.2", "1.3"}},
330 {"network.compression", "Compression algorithm", false,
331 "UNIFIED_NETWORK_COMPRESSION", {"none", "lz4", "gzip", "deflate", "zstd"}},
332 {"network.buffer_size", "I/O buffer size", false,
333 "UNIFIED_NETWORK_BUFFER_SIZE", {}},
334 };
335}

Referenced by kcenon::common::config::cli_config_parser::print_help().

Here is the caller graph for this function:

◆ is_hot_reloadable()

bool kcenon::common::config::is_hot_reloadable ( const std::string & field_path)
inline

Check if a configuration field supports hot-reload.

Parameters
field_pathThe dot-separated field path
Returns
true if the field can be changed at runtime

Definition at line 342 of file unified_config.h.

342 {
343 static const std::vector<std::string> hot_reloadable_fields = {
344 "logger.level",
345 "logger.file_path",
346 "monitoring.metrics_interval",
347 "monitoring.tracing.sampling_rate",
348 };
349
350 for (const auto& field : hot_reloadable_fields) {
351 if (field_path == field) {
352 return true;
353 }
354 }
355 return false;
356}

Referenced by kcenon::common::config::config_watcher::do_reload().

Here is the caller graph for this function:

Variable Documentation

◆ ENV_PREFIX

const char* kcenon::common::config::ENV_PREFIX = "UNIFIED_"
constexpr

Environment variable prefix for configuration overrides.

All environment variables should be prefixed with UNIFIED_ and use underscores to separate nested keys.

Examples:

  • UNIFIED_THREAD_POOL_SIZE=16
  • UNIFIED_LOGGER_LEVEL=debug
  • UNIFIED_MONITORING_ENABLED=false
  • UNIFIED_DATABASE_CONNECTION_STRING=postgresql://localhost/mydb
  • UNIFIED_NETWORK_TLS_ENABLED=true

Definition at line 257 of file unified_config.h.