Skip to content

Commit e0ce540

Browse files
authored
refactor(modules): update C++20 module files for upstream ecosystem changes (#223) (#234)
* refactor(modules): update C++20 module files for upstream ecosystem changes (Issue #223) - Update transport_interface to match actual header API: disconnect() returns VoidResult, rename state() to get_state(), replace send_async() with send_binary(), add statistics methods - Replace transport_options with transport_config/transport_statistics - Rewrite websocket_transport with proper config and topic methods - Rewrite http_transport with http_content_type and config structs - Replace resilient_transport with retry_config, circuit_breaker_config, resilient_transport_config, and resilience_statistics from Issue #221 - Add messaging_error_category and make_messaging_error_code to core partition from Issue #229 - Add health check adapter exports (messaging_health_check, queue_health_check, transport_health_check) from Issue #222 - Add composite check and registration helper exports * fix(modules): resolve C++20 module build configuration issues - Fix INTERFACE library target handling in UnifiedDependencies.cmake (use INTERFACE keyword instead of PUBLIC for INTERFACE targets) - Link messaging_system_modules to messaging_system_core for proper upstream include path propagation during dependency scanning - Remove non-existent kcenon.logger module import (logging is part of kcenon.common:logging partition) - Replace kcenon.database import with kcenon.monitoring (database_system has upstream CMake module build bug) - Use foreach loop for cleaner upstream module target linking
1 parent 5d92acf commit e0ce540

5 files changed

Lines changed: 435 additions & 203 deletions

File tree

CMakeLists.txt

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -476,33 +476,28 @@ if(MESSAGING_BUILD_MODULES)
476476
$<INSTALL_INTERFACE:include>
477477
)
478478

479-
# Link dependencies - module targets from dependent systems
480-
# Note: These targets must be available when building with modules
481-
if(TARGET kcenon::common_modules)
482-
target_link_libraries(messaging_system_modules PUBLIC kcenon::common_modules)
483-
endif()
484-
if(TARGET kcenon::thread_modules)
485-
target_link_libraries(messaging_system_modules PUBLIC kcenon::thread_modules)
486-
endif()
487-
if(TARGET kcenon::container_modules)
488-
target_link_libraries(messaging_system_modules PUBLIC kcenon::container_modules)
489-
endif()
490-
if(TARGET kcenon::logger_modules)
491-
target_link_libraries(messaging_system_modules PUBLIC kcenon::logger_modules)
492-
endif()
493-
if(TARGET kcenon::database_modules)
494-
target_link_libraries(messaging_system_modules PUBLIC kcenon::database_modules)
495-
endif()
496-
if(TARGET kcenon::network_modules)
497-
target_link_libraries(messaging_system_modules PUBLIC kcenon::network_modules)
498-
endif()
499-
500-
# Also link header-based targets for implementation files
501-
if(TARGET ${container_system_TARGET})
502-
target_link_libraries(messaging_system_modules PRIVATE ${container_system_TARGET})
503-
elseif(TARGET container)
504-
target_link_libraries(messaging_system_modules PRIVATE container)
505-
endif()
479+
# Link dependencies for module compilation.
480+
# The global module fragment #includes upstream headers (e.g., core/container.h),
481+
# so we need their include directories available during dependency scanning.
482+
# Link to messaging_system_core (PRIVATE) to transitively get all upstream
483+
# include paths, then optionally link upstream module targets (PUBLIC) when
484+
# they become available.
485+
target_link_libraries(messaging_system_modules PRIVATE messaging_system_core)
486+
487+
# When upstream systems provide C++20 module targets, link them publicly
488+
# so consumers can import the full module dependency chain.
489+
foreach(_mod_target
490+
kcenon::common_modules
491+
kcenon::thread_modules
492+
kcenon::container_modules
493+
kcenon::logger_modules
494+
kcenon::database_modules
495+
kcenon::network_modules
496+
)
497+
if(TARGET ${_mod_target})
498+
target_link_libraries(messaging_system_modules PUBLIC ${_mod_target})
499+
endif()
500+
endforeach()
506501

507502
# Define compile-time flags
508503
target_compile_definitions(messaging_system_modules PUBLIC

cmake/UnifiedDependencies.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,12 @@ macro(_unified_resolve_fetchcontent DEP_NAME GIT_TAG)
482482
if(TARGET "${_ts_target}")
483483
get_target_property(_aliased "${_ts_target}" ALIASED_TARGET)
484484
if(NOT _aliased)
485-
target_compile_definitions("${_ts_target}" PUBLIC USE_STD_FORMAT)
485+
get_target_property(_ts_type "${_ts_target}" TYPE)
486+
if(_ts_type STREQUAL "INTERFACE_LIBRARY")
487+
target_compile_definitions("${_ts_target}" INTERFACE USE_STD_FORMAT)
488+
else()
489+
target_compile_definitions("${_ts_target}" PUBLIC USE_STD_FORMAT)
490+
endif()
486491
endif()
487492
endif()
488493
endforeach()

src/modules/core.cppm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,3 +813,46 @@ constexpr std::string_view get_error_message(int code) noexcept {
813813
}
814814

815815
} // namespace kcenon::messaging::error
816+
817+
// =============================================================================
818+
// Error Category
819+
// =============================================================================
820+
821+
export namespace kcenon::messaging {
822+
823+
/**
824+
* @class messaging_error_category
825+
* @brief Error category for messaging_system typed error codes
826+
*
827+
* Integrates with common_system's typed_error_code infrastructure.
828+
* Singleton pattern, thread-safe via C++11 static local initialization.
829+
*/
830+
class messaging_error_category : public common::error_category {
831+
public:
832+
static const messaging_error_category& instance() noexcept {
833+
static messaging_error_category inst;
834+
return inst;
835+
}
836+
837+
std::string_view name() const noexcept override {
838+
return "messaging";
839+
}
840+
841+
std::string message(int code) const override {
842+
return std::string(error::get_error_message(code));
843+
}
844+
845+
private:
846+
messaging_error_category() = default;
847+
};
848+
849+
/**
850+
* @brief Create a typed_error_code for a messaging error code
851+
* @param code Messaging error code (from error:: namespace)
852+
* @return typed_error_code with messaging_error_category
853+
*/
854+
inline common::typed_error_code make_messaging_error_code(int code) noexcept {
855+
return common::typed_error_code(code, messaging_error_category::instance());
856+
}
857+
858+
} // namespace kcenon::messaging

0 commit comments

Comments
 (0)