hmon: rework error handling in FFI#87
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
There was a problem hiding this comment.
Pull request overview
This PR reworks the Health Monitoring (HMON) Rust↔C++ FFI surface to use a uniform return-code-based error model, updates the C++ wrappers to construct objects via factory methods returning expected, and adds Rust unit tests covering the FFI functions (in support of avoiding panics/terminates across extern "C" boundaries).
Changes:
- Introduce a shared
FFICodeand convert Rust FFI functions to return it (with out-params for handles). - Update C++ wrappers/builders to use
::create()factory methods andexpected<..., Error>for fallible construction/build. - Add/expand Rust unit tests for FFI functions and adjust the C++ tests to the new API.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/health_monitoring_lib/rust/lib.rs | Documentation tweak for builder creation/build. |
| src/health_monitoring_lib/rust/ffi.rs | New FFICode/FFIHandle, reworked HM FFI API + extensive Rust tests. |
| src/health_monitoring_lib/rust/deadline/ffi.rs | Reworked deadline FFI API to FFICode + Rust tests. |
| src/health_monitoring_lib/rust/common.rs | Removes old common::ffi module in favor of crate::ffi. |
| src/health_monitoring_lib/cpp/include/score/hm/common.h | Introduces internal FFICode/kSuccess, updates Error codes & drop-fn signature. |
| src/health_monitoring_lib/cpp/include/score/hm/health_monitor.h | Builder now uses create() + expected and build() becomes fallible. |
| src/health_monitoring_lib/cpp/include/score/hm/deadline/deadline_monitor.h | Deadline builder now uses create() + expected. |
| src/health_monitoring_lib/cpp/health_monitor.cpp | Implements new FFI signatures and expected-based factory/build paths. |
| src/health_monitoring_lib/cpp/deadline_monitor.cpp | Implements new FFI signatures and expected-based factory paths. |
| src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp | Updates test to use create().value() and fallible build().value(). |
| src/health_monitoring_lib/BUILD | Removes deleted cpp/ffi_helpers.h from sources. |
| src/health_monitoring_lib/cpp/ffi_helpers.h | Deleted legacy error mapping helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f78336e to
507d936
Compare
src/health_monitoring_lib/cpp/include/score/hm/health_monitor.h
Outdated
Show resolved
Hide resolved
507d936 to
d179c88
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d179c88 to
4b2a346
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/health_monitoring_lib/cpp/health_monitor.cpp:136
- The destructor calls health_monitor_destroy but ignores the returned FFICode. While ignoring errors in destructors is sometimes acceptable, this inconsistency could mask issues. Consider using abort_on_error for consistency with other parts of the codebase, or explicitly document why errors are ignored in destructors.
HealthMonitor::~HealthMonitor()
{
if (health_monitor_ != nullptr)
{
health_monitor_destroy(health_monitor_);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4b2a346 to
6f0335a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6f0335a to
69fcbc8
Compare
69fcbc8 to
fcfb27c
Compare
fcfb27c to
a130396
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a130396 to
74707b4
Compare
| { | ||
| if (code != kSuccess) | ||
| { | ||
| std::abort(); |
There was a problem hiding this comment.
std::terminate shall be used. But shdnt we use baselib macro for that ? One of SCORE_LANGUAGE_FUTURECPP_PRECONDITION or maybe other - can you check?
There was a problem hiding this comment.
SCORE_LANGUAGE_FUTURECPP_ASSERT can be used.
- Uniformly return `FFICode` in FFI functions. - Unit tests for FFI functions in Rust. - Rework comments for FFI functions. - Move `crate::common::ffi` to `crate::ffi`.
74707b4 to
fd99f6c
Compare
FFICodein FFI functions.crate::common::ffitocrate::ffi.Closes #82