PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
remote_node_manager.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
20#pragma once
21
25
26#include <chrono>
27#include <future>
28#include <memory>
29#include <mutex>
30#include <span>
31#include <string>
32#include <string_view>
33#include <vector>
34
35// Forward declarations
36namespace kcenon::pacs::storage {
37class node_repository;
38}
39
41class association;
42}
43
44namespace kcenon::pacs::client {
45
46// =============================================================================
47// Remote Node Manager
48// =============================================================================
49
94public:
95 // =========================================================================
96 // Construction / Destruction
97 // =========================================================================
98
106 explicit remote_node_manager(
107 std::shared_ptr<storage::node_repository> repo,
109 std::shared_ptr<di::ILogger> logger = nullptr);
110
115
116 // Non-copyable, non-movable (due to internal threading)
121
122 // =========================================================================
123 // Node CRUD Operations
124 // =========================================================================
125
132 [[nodiscard]] auto add_node(const remote_node& node) -> kcenon::pacs::VoidResult;
133
140 [[nodiscard]] auto update_node(const remote_node& node) -> kcenon::pacs::VoidResult;
141
148 [[nodiscard]] auto remove_node(std::string_view node_id) -> kcenon::pacs::VoidResult;
149
156 [[nodiscard]] auto get_node(std::string_view node_id) const
157 -> std::optional<remote_node>;
158
164 [[nodiscard]] auto list_nodes() const -> std::vector<remote_node>;
165
172 [[nodiscard]] auto list_nodes_by_status(node_status status) const
173 -> std::vector<remote_node>;
174
175 // =========================================================================
176 // Connection Verification (C-ECHO)
177 // =========================================================================
178
188 [[nodiscard]] auto verify_node(std::string_view node_id) -> kcenon::pacs::VoidResult;
189
198 [[nodiscard]] auto verify_node_async(std::string_view node_id)
199 -> std::future<kcenon::pacs::VoidResult>;
200
208
209 // =========================================================================
210 // Association Pool Management
211 // =========================================================================
212
223 [[nodiscard]] auto acquire_association(
224 std::string_view node_id,
225 std::span<const std::string> sop_classes)
226 -> kcenon::pacs::Result<std::unique_ptr<network::association>>;
227
239 std::string_view node_id,
240 std::unique_ptr<network::association> assoc);
241
242 // =========================================================================
243 // Health Check Scheduler
244 // =========================================================================
245
252 void start_health_check();
253
259 void stop_health_check();
260
266 [[nodiscard]] auto is_health_check_running() const noexcept -> bool;
267
268 // =========================================================================
269 // Status Monitoring
270 // =========================================================================
271
278 [[nodiscard]] auto get_status(std::string_view node_id) const -> node_status;
279
289
290 // =========================================================================
291 // Statistics
292 // =========================================================================
293
300 [[nodiscard]] auto get_statistics(std::string_view node_id) const
302
308 void reset_statistics(std::string_view node_id = "");
309
310 // =========================================================================
311 // Configuration
312 // =========================================================================
313
319 [[nodiscard]] auto config() const noexcept -> const node_manager_config&;
320
328 void set_config(node_manager_config new_config);
329
330private:
331 // =========================================================================
332 // Private Implementation
333 // =========================================================================
334
335 struct impl;
336 std::unique_ptr<impl> impl_;
337};
338
339} // namespace kcenon::pacs::client
void start_health_check()
Start the automatic health check scheduler.
auto is_health_check_running() const noexcept -> bool
Check if health check is running.
auto get_statistics(std::string_view node_id) const -> node_statistics
Get statistics for a node.
auto update_node(const remote_node &node) -> kcenon::pacs::VoidResult
Update an existing remote node.
auto get_node(std::string_view node_id) const -> std::optional< remote_node >
Get a node by ID.
auto get_status(std::string_view node_id) const -> node_status
Get the current status of a node.
~remote_node_manager()
Destructor - stops health check if running.
remote_node_manager(const remote_node_manager &)=delete
void verify_all_nodes_async()
Verify all nodes asynchronously.
auto operator=(remote_node_manager &&) -> remote_node_manager &=delete
void stop_health_check()
Stop the automatic health check scheduler.
remote_node_manager(std::shared_ptr< storage::node_repository > repo, node_manager_config config={}, std::shared_ptr< di::ILogger > logger=nullptr)
Construct a remote node manager.
auto verify_node(std::string_view node_id) -> kcenon::pacs::VoidResult
Verify a node's connectivity synchronously.
auto list_nodes_by_status(node_status status) const -> std::vector< remote_node >
List nodes filtered by status.
auto remove_node(std::string_view node_id) -> kcenon::pacs::VoidResult
Remove a remote node.
auto list_nodes() const -> std::vector< remote_node >
List all registered nodes.
auto acquire_association(std::string_view node_id, std::span< const std::string > sop_classes) -> kcenon::pacs::Result< std::unique_ptr< network::association > >
Acquire an association from the pool.
void reset_statistics(std::string_view node_id="")
Reset statistics for a node.
auto config() const noexcept -> const node_manager_config &
Get the current configuration.
void set_config(node_manager_config new_config)
Update the configuration.
void set_status_callback(node_status_callback callback)
Set the status change callback.
auto add_node(const remote_node &node) -> kcenon::pacs::VoidResult
Add a new remote node.
remote_node_manager(remote_node_manager &&)=delete
void release_association(std::string_view node_id, std::unique_ptr< network::association > assoc)
Release an association back to the pool.
auto operator=(const remote_node_manager &) -> remote_node_manager &=delete
auto verify_node_async(std::string_view node_id) -> std::future< kcenon::pacs::VoidResult >
Verify a node's connectivity asynchronously.
Logger interface for dependency injection.
node_status
Status of a remote PACS node.
Definition remote_node.h:51
std::function< void(std::string_view node_id, node_status status)> node_status_callback
Callback function type for node status changes.
Remote PACS node data structures for client operations.
Result<T> type aliases and helpers for PACS system.
Configuration for the remote node manager.
Statistics for a remote node.