13#if KCENON_WITH_MONITORING_SYSTEM
32 return error_void(already_exists,
"Network system already initialized",
"network_system");
39 if (
config.thread_pool.worker_count >= 0) {
40 auto thread_pool = std::make_shared<integration::basic_thread_pool>(
41 config.thread_pool.worker_count == 0
42 ? std::thread::hardware_concurrency()
43 :
config.thread_pool.worker_count);
44 ctx.set_thread_pool(thread_pool);
45 ctx.initialize(
config.thread_pool.worker_count);
50#if KCENON_WITH_COMMON_SYSTEM
51 auto logger = std::make_shared<integration::common_system_logger_adapter>();
53 auto logger = std::make_shared<integration::basic_logger>(
config.logger.min_level);
55 ctx.set_logger(logger);
59#if KCENON_WITH_MONITORING_SYSTEM
60 if (
config.monitoring.enabled) {
62 std::make_shared<integration::monitoring_system_adapter>(
63 config.monitoring.service_name);
66 ctx.set_monitoring(monitoring);
76 }
catch (
const std::exception &e) {
78 std::string(e.what()));
79 return error_void(internal_error, std::string(
"Initialization failed: ") + e.what(),
"network_system");
84#if KCENON_WITH_COMMON_SYSTEM
87 if (config_with_dependencies.
executor) {
89 std::make_shared<integration::common_thread_pool_adapter>(
91 ctx.set_thread_pool(pool_adapter);
94 if (config_with_dependencies.
logger) {
95 auto logger_adapter = std::make_shared<integration::common_logger_adapter>(
96 config_with_dependencies.
logger);
97 ctx.set_logger(logger_adapter);
100#if KCENON_WITH_MONITORING_SYSTEM
101 if (config_with_dependencies.
monitor) {
102 auto monitoring_adapter =
103 std::make_shared<integration::common_monitoring_adapter>(
104 config_with_dependencies.
monitor);
105 ctx.set_monitoring(monitoring_adapter);
109 (void)config_with_dependencies;
117 return error_void(not_initialized,
"Network system not initialized",
"network_system");
130 }
catch (
const std::exception &e) {
132 std::string(e.what()));
133 return error_void(internal_error, std::string(
"Shutdown failed: ") + e.what(),
"network_system");
static network_context & instance()
Get the singleton instance.
static logger_integration_manager & instance()
Get the singleton instance.
void set_logger(std::shared_ptr< logger_interface > logger)
Set the logger implementation.
Adapter for common_system integration.
Feature flags for network_system.
Logger system integration interface for network_system.
#define NETWORK_LOG_WARN(msg)
#define NETWORK_LOG_INFO(msg)
#define NETWORK_LOG_ERROR(msg)
Monitoring system integration interface for network_system.
constexpr int not_initialized
constexpr int internal_error
constexpr int already_exists
Main namespace for all Network System components.
bool is_initialized()
Check if network system is initialized.
VoidResult error_void(int code, const std::string &message, const std::string &source="network_system", const std::string &details="")
VoidResult initialize()
Initialize the network system with default production configuration.
static std::atomic< bool > g_initialized
VoidResult shutdown()
Shutdown the network system.
Global context for shared network system resources.
Main header for the Network System.
Configuration for standalone network_system initialization.
static network_config production()
Create production configuration.
Configuration for network_system with external dependencies.
std::shared_ptr< kcenon::common::interfaces::IExecutor > executor
External executor/thread pool (nullptr = create internal)
network_config runtime
Runtime configuration settings (thread pool, logger, monitoring config)
std::shared_ptr< kcenon::common::interfaces::ILogger > logger
External logger instance (nullptr = create internal)
std::shared_ptr< kcenon::common::interfaces::IMonitor > monitor
External monitoring instance (nullptr = create internal if enabled)
Thread system integration interface for network_system.