Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
network_system_bridge.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6
46#include "kcenon/network/internal/integration/bridge_interface.h"
47#include "kcenon/network/internal/integration/thread_pool_bridge.h"
49#include "kcenon/network/internal/integration/logger_integration.h"
50#include "kcenon/network/internal/integration/monitoring_integration.h"
52
53#if KCENON_WITH_COMMON_SYSTEM
54#include <kcenon/common/interfaces/executor_interface.h>
55#include <kcenon/common/interfaces/logger_interface.h>
56#include <kcenon/common/interfaces/monitoring_interface.h>
57#endif
58
59#include <memory>
60#include <string>
61#include <map>
62#include <mutex>
63#include <optional>
64
66
78 std::string integration_name = "network_system";
79
83 bool enable_thread_pool = true;
84
88 bool enable_logger = false;
89
93 bool enable_monitoring = false;
94
102 std::map<std::string, std::string> thread_pool_properties;
103
111 std::map<std::string, std::string> logger_properties;
112
120 std::map<std::string, std::string> monitoring_properties;
121};
122
150public:
158
166 explicit NetworkSystemBridge(std::shared_ptr<ThreadPoolBridge> thread_pool);
167
174
175 // Non-copyable, movable
180
208
217
222 bool is_initialized() const;
223
232
233 // Bridge Component Access
234
239 std::shared_ptr<ThreadPoolBridge> get_thread_pool_bridge() const;
240
251 std::shared_ptr<thread_pool_interface> get_thread_pool() const;
252
257 std::shared_ptr<logger_interface> get_logger() const;
258
263 std::shared_ptr<monitoring_interface> get_monitoring() const;
264
265 // Configuration Methods
266
279
287 VoidResult set_logger(std::shared_ptr<logger_interface> logger);
288
296 VoidResult set_monitoring(std::shared_ptr<monitoring_interface> monitoring);
297
298 // Factory Methods
299
316 static std::shared_ptr<NetworkSystemBridge> create_default();
317
333 static std::shared_ptr<NetworkSystemBridge> with_thread_system(
334 const std::string& pool_name = "network_pool");
335
336#if KCENON_WITH_COMMON_SYSTEM
357 static std::shared_ptr<NetworkSystemBridge> with_common_system(
358 std::shared_ptr<::kcenon::common::interfaces::IExecutor> executor,
359 std::shared_ptr<::kcenon::common::interfaces::ILogger> logger = nullptr,
360 std::shared_ptr<::kcenon::common::interfaces::IMonitor> monitor = nullptr);
361#endif
362
372 static std::shared_ptr<NetworkSystemBridge> with_custom(
373 std::shared_ptr<thread_pool_interface> thread_pool = nullptr,
374 std::shared_ptr<logger_interface> logger = nullptr,
375 std::shared_ptr<monitoring_interface> monitoring = nullptr);
376
377private:
378 class Impl;
379 std::unique_ptr<Impl> pimpl_;
380};
381
382} // namespace kcenon::network::integration
383
384// Backward compatibility namespace alias
Unified facade for all network_system integration bridges.
NetworkSystemBridge & operator=(const NetworkSystemBridge &)=delete
static std::shared_ptr< NetworkSystemBridge > create_default()
Create bridge with default configuration.
std::shared_ptr< thread_pool_interface > get_thread_pool() const
Get thread pool interface.
std::shared_ptr< logger_interface > get_logger() const
Get logger interface.
static std::shared_ptr< NetworkSystemBridge > with_custom(std::shared_ptr< thread_pool_interface > thread_pool=nullptr, std::shared_ptr< logger_interface > logger=nullptr, std::shared_ptr< monitoring_interface > monitoring=nullptr)
Create bridge with custom components.
VoidResult set_thread_pool_bridge(std::shared_ptr< ThreadPoolBridge > bridge)
Set custom thread pool bridge.
bool is_initialized() const
Check if the bridge is initialized.
std::shared_ptr< ThreadPoolBridge > get_thread_pool_bridge() const
Get thread pool bridge.
BridgeMetrics get_metrics() const
Get aggregated metrics from all bridges.
static std::shared_ptr< NetworkSystemBridge > with_thread_system(const std::string &pool_name="network_pool")
Create bridge with thread_system integration.
NetworkSystemBridge(const NetworkSystemBridge &)=delete
std::shared_ptr< monitoring_interface > get_monitoring() const
Get monitoring interface.
NetworkSystemBridge(NetworkSystemBridge &&) noexcept
VoidResult set_monitoring(std::shared_ptr< monitoring_interface > monitoring)
Set custom monitoring.
VoidResult set_logger(std::shared_ptr< logger_interface > logger)
Set custom logger.
Bridge for thread pool integration implementing INetworkBridge.
Interface for logger integration.
Definition core.cppm:112
Interface for monitoring integration.
Definition core.cppm:147
Interface for thread pool integration.
Definition core.cppm:83
Public header for compile-time feature flags.
VoidResult initialize()
Initialize the network system with default production configuration.
Metrics and health information for a bridge.
std::map< std::string, std::string > monitoring_properties
Monitoring configuration properties.
std::map< std::string, std::string > logger_properties
Logger configuration properties.
std::map< std::string, std::string > thread_pool_properties
Thread pool configuration properties.
Thread system integration interface for network_system.