Skip to content

Commit a535d24

Browse files
authored
refactor(internal): move integration headers to internal (#639)
Move implementation detail headers from include/kcenon/network/integration/ to src/internal/integration/ to reduce public API surface. Migrated headers: - bridge_interface.h - common_system_adapter.h - container_integration.h - io_context_thread_manager.h - logger_integration.h - messaging_bridge.h - monitoring_integration.h - observability_bridge.h - thread_pool_adapters.h - thread_pool_bridge.h - thread_system_adapter.h Public headers converted to deprecated stubs that include internal headers. thread_integration.h and network_system_bridge.h remain as public API. Closes #638
1 parent 6e9f6aa commit a535d24

76 files changed

Lines changed: 3497 additions & 2969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 294 deletions
Original file line numberDiff line numberDiff line change
@@ -1,297 +1,48 @@
1-
// BSD 3-Clause License
2-
//
3-
// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
4-
//
5-
// Redistribution and use in source and binary forms, with or without
6-
// modification, are permitted provided that the following conditions are met:
7-
//
8-
// 1. Redistributions of source code must retain the above copyright notice, this
9-
// list of conditions and the following disclaimer.
10-
//
11-
// 2. Redistributions in binary form must reproduce the above copyright notice,
12-
// this list of conditions and the following disclaimer in the documentation
13-
// and/or other materials provided with the distribution.
14-
//
15-
// 3. Neither the name of the copyright holder nor the names of its
16-
// contributors may be used to endorse or promote products derived from
17-
// this software without specific prior written permission.
18-
//
19-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20-
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21-
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22-
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23-
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24-
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26-
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27-
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1+
/*****************************************************************************
2+
BSD 3-Clause License
3+
4+
Copyright (c) 2024, kcenon
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
1. Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
2. Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
3. Neither the name of the copyright holder nor the names of its
18+
contributors may be used to endorse or promote products derived from
19+
this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*****************************************************************************/
2932

3033
#pragma once
3134

32-
/**
33-
* @file bridge_interface.h
34-
* @brief Unified interface for external system integration bridges
35-
*
36-
* This file defines the core interface for all integration bridges in network_system.
37-
* A bridge provides a consistent way to integrate with external systems while
38-
* maintaining lifecycle management, configuration, and metrics reporting.
39-
*
40-
* Design Goals:
41-
* - Unified interface for all external system integrations
42-
* - Consistent lifecycle management (initialize, shutdown)
43-
* - Configuration support for runtime adaptation
44-
* - Health and metrics reporting
45-
* - Type-safe error handling via Result<T>
46-
*
47-
* Usage Example:
48-
* @code
49-
* class ThreadPoolBridge : public INetworkBridge {
50-
* public:
51-
* Result<void> initialize(const BridgeConfig& config) override {
52-
* // Setup thread pool with config parameters
53-
* return ok();
54-
* }
55-
*
56-
* Result<void> shutdown() override {
57-
* // Gracefully shutdown thread pool
58-
* return ok();
59-
* }
60-
*
61-
* // ... other INetworkBridge methods
62-
* };
63-
* @endcode
64-
*
65-
* Related Issues:
66-
* - #579: Consolidate integration adapters into NetworkSystemBridge
67-
* - #577: EPIC for Facade pattern refactoring
68-
*
69-
* @author network_system team
70-
* @date 2026-02-01
71-
*/
72-
73-
#include <kcenon/network/utils/result_types.h>
74-
#include <chrono>
75-
#include <map>
76-
#include <string>
77-
78-
namespace kcenon::network::integration {
79-
80-
/**
81-
* @struct BridgeConfig
82-
* @brief Configuration for bridge initialization
83-
*
84-
* This structure provides a flexible key-value configuration mechanism
85-
* for bridges. Each bridge type interprets the properties map according
86-
* to its specific needs.
87-
*
88-
* Example:
89-
* @code
90-
* BridgeConfig config;
91-
* config.integration_name = "thread_system";
92-
* config.properties["pool_name"] = "network_pool";
93-
* config.properties["worker_count"] = "8";
94-
* @endcode
95-
*/
96-
struct BridgeConfig {
97-
/**
98-
* @brief Name identifying the external system being integrated
99-
*
100-
* Examples: "thread_system", "common_system", "messaging_system"
101-
*/
102-
std::string integration_name;
103-
104-
/**
105-
* @brief Key-value properties for bridge-specific configuration
106-
*
107-
* Property keys and values are bridge-specific. Common properties:
108-
* - "worker_count": Number of worker threads
109-
* - "pool_name": Thread pool identifier
110-
* - "enable_logging": Enable/disable logging
111-
* - "log_level": Minimum log level
112-
*/
113-
std::map<std::string, std::string> properties;
114-
};
115-
116-
/**
117-
* @struct BridgeMetrics
118-
* @brief Metrics and health information for a bridge
119-
*
120-
* This structure provides standardized metrics reporting across all bridges.
121-
* Each bridge can extend with custom metrics via the custom_metrics map.
122-
*
123-
* Example:
124-
* @code
125-
* BridgeMetrics metrics;
126-
* metrics.is_healthy = true;
127-
* metrics.last_activity = std::chrono::steady_clock::now();
128-
* metrics.custom_metrics["pending_tasks"] = 42.0;
129-
* metrics.custom_metrics["worker_threads"] = 8.0;
130-
* @endcode
131-
*/
132-
struct BridgeMetrics {
133-
/**
134-
* @brief Overall health status of the bridge
135-
*
136-
* false indicates the bridge has encountered errors or is in degraded state
137-
*/
138-
bool is_healthy{true};
139-
140-
/**
141-
* @brief Timestamp of last activity or health check
142-
*
143-
* Updated when the bridge performs operations or reports health
144-
*/
145-
std::chrono::steady_clock::time_point last_activity;
146-
147-
/**
148-
* @brief Bridge-specific custom metrics
149-
*
150-
* Each bridge can report custom metrics here. Common metric names:
151-
* - "pending_tasks": Number of queued tasks (thread pools)
152-
* - "worker_threads": Number of worker threads
153-
* - "messages_sent": Total messages sent (messaging bridges)
154-
* - "connections_active": Active connections
155-
* - "error_count": Number of errors encountered
156-
*/
157-
std::map<std::string, double> custom_metrics;
158-
};
159-
160-
/**
161-
* @class INetworkBridge
162-
* @brief Abstract interface for external system integration bridges
163-
*
164-
* This interface defines the contract for all integration bridges in network_system.
165-
* Each bridge provides a consistent way to:
166-
* - Initialize with configuration
167-
* - Manage lifecycle (shutdown)
168-
* - Report health and metrics
169-
* - Check initialization status
170-
*
171-
* Lifecycle:
172-
* 1. Construct bridge instance
173-
* 2. Call initialize() with configuration
174-
* 3. Use bridge functionality
175-
* 4. Call shutdown() before destruction
176-
*
177-
* Thread Safety:
178-
* - Implementations should be thread-safe for concurrent metric queries
179-
* - initialize() and shutdown() need not be thread-safe (call from one thread)
180-
*
181-
* Error Handling:
182-
* - All operations return Result<T> for type-safe error propagation
183-
* - Failed initialization should prevent bridge usage
184-
* - Shutdown should always succeed or log errors internally
185-
*/
186-
class INetworkBridge {
187-
public:
188-
virtual ~INetworkBridge() = default;
189-
190-
/**
191-
* @brief Initialize the bridge with configuration
192-
* @param config Configuration parameters for the bridge
193-
* @return ok() on success, error_info on failure
194-
*
195-
* This method must be called before using the bridge. Initialization
196-
* sets up the external system integration according to the provided
197-
* configuration.
198-
*
199-
* Error Conditions:
200-
* - Invalid configuration parameters
201-
* - External system unavailable
202-
* - Resource allocation failure
203-
* - Already initialized
204-
*
205-
* Example:
206-
* @code
207-
* BridgeConfig config;
208-
* config.integration_name = "thread_system";
209-
* config.properties["pool_name"] = "network_pool";
210-
*
211-
* auto result = bridge->initialize(config);
212-
* if (result.is_err()) {
213-
* std::cerr << "Failed to initialize: " << result.error().message << std::endl;
214-
* return;
215-
* }
216-
* @endcode
217-
*/
218-
virtual VoidResult initialize(const BridgeConfig& config) = 0;
219-
220-
/**
221-
* @brief Shutdown the bridge and release resources
222-
* @return ok() on success, error_info on failure
223-
*
224-
* This method should be called before destroying the bridge. It
225-
* gracefully shuts down the external system integration and releases
226-
* any held resources.
227-
*
228-
* Shutdown should be idempotent - calling shutdown() multiple times
229-
* should not cause errors.
230-
*
231-
* Error Conditions:
232-
* - Resource cleanup failure (should log but not throw)
233-
* - External system communication error
234-
*
235-
* Example:
236-
* @code
237-
* auto result = bridge->shutdown();
238-
* if (result.is_err()) {
239-
* std::cerr << "Shutdown error: " << result.error().message << std::endl;
240-
* }
241-
* @endcode
242-
*/
243-
virtual VoidResult shutdown() = 0;
244-
245-
/**
246-
* @brief Check if the bridge is initialized and ready for use
247-
* @return true if initialized, false otherwise
248-
*
249-
* This method provides a quick way to check if the bridge has been
250-
* successfully initialized and is ready for operation.
251-
*
252-
* Returns false if:
253-
* - initialize() has not been called
254-
* - initialize() failed
255-
* - shutdown() has been called
256-
*
257-
* Example:
258-
* @code
259-
* if (!bridge->is_initialized()) {
260-
* std::cerr << "Bridge not initialized" << std::endl;
261-
* return;
262-
* }
263-
* // Use bridge functionality
264-
* @endcode
265-
*/
266-
virtual bool is_initialized() const = 0;
267-
268-
/**
269-
* @brief Get current metrics and health information
270-
* @return Current bridge metrics
271-
*
272-
* This method returns health and performance metrics for the bridge.
273-
* It should be lightweight and suitable for frequent polling.
274-
*
275-
* Thread Safety: Must be safe to call concurrently from multiple threads
276-
*
277-
* Example:
278-
* @code
279-
* auto metrics = bridge->get_metrics();
280-
* if (!metrics.is_healthy) {
281-
* std::cerr << "Bridge unhealthy" << std::endl;
282-
* }
283-
*
284-
* if (metrics.custom_metrics.count("pending_tasks") > 0) {
285-
* std::cout << "Pending tasks: " << metrics.custom_metrics["pending_tasks"] << std::endl;
286-
* }
287-
* @endcode
288-
*/
289-
virtual BridgeMetrics get_metrics() const = 0;
290-
};
291-
292-
} // namespace kcenon::network::integration
293-
294-
// Backward compatibility namespace alias
295-
namespace network_system {
296-
namespace integration = kcenon::network::integration;
297-
}
35+
// DEPRECATED: This header location is deprecated.
36+
// Please use facade headers for new code.
37+
#ifndef NETWORK_SYSTEM_SUPPRESS_DEPRECATION_WARNINGS
38+
#if defined(__GNUC__) || defined(__clang__)
39+
#pragma message("DEPRECATED: include path 'kcenon/network/integration/bridge_interface.h' is deprecated. " \
40+
"Use 'kcenon/network/integration/network_system_bridge.h' instead.")
41+
#elif defined(_MSC_VER)
42+
#pragma message("DEPRECATED: include path 'kcenon/network/integration/bridge_interface.h' is deprecated. " \
43+
"Use 'kcenon/network/integration/network_system_bridge.h' instead.")
44+
#endif
45+
#endif
46+
47+
// Include internal header for backward compatibility
48+
#include "internal/integration/bridge_interface.h"

0 commit comments

Comments
 (0)