Refactor Monitor API to public Alive API#229
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
| score_testing_macros.workspace = true | ||
| containers.workspace = true | ||
| monitor_rs = { workspace = true, optional = true } | ||
| alive_rs = { workspace = true, optional = true } |
There was a problem hiding this comment.
is optional correct here?
There was a problem hiding this comment.
I suppose that is optional because there is also a stub implementation for the interface within health_monitor.
But the cargo build is not working for me locally, neither before nor with these changes.
Is the cargo build still in use @pawelrutkaq ?
|
|
||
| private: | ||
| /// @brief Unique pointer to implementation class of Alive | ||
| std::unique_ptr<AliveImpl> aliveImplPtr; |
There was a problem hiding this comment.
this pimpl Alive (AliveImpl), does not sound as any benefit really here.
There was a problem hiding this comment.
The benefit of the pimpl is that we can keep the public API minimal.
If I were to remove the AliveImpl class everything that is included there would need to become now part of the public API and those classes are meant to stay internal so that we can freely change them later.
There was a problem hiding this comment.
not really in my opinion - public is what is public that is. rest can be private/protected and you change it. pimpl here is just code duplication.
There was a problem hiding this comment.
I think there are two big benefits here for using pimpl pattern.
1. Keeping implementation details private
The AliveImpl header includes the following internal headers:
#include "score/mw/launch_manager/alive_monitor/details/ifappl/DataStructures.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ipc/IpcClient.hpp"
#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp"
which again include other internal headers.
When removing the AliveImpl class, those headers would go to the Alive header and thus be required to be part of the public API (+all their transitive headers).
Those are all implementation details that should stay private, otherwise we risk easily breaking users when we change those classes in the future. Furthermore, users may start relying on these implementation details (e.g. specific shared memory layout as defined in DataStructures.hpp).
2. ABI compatibility
Size and layout of Alive class will stay unchanged. This can become important when delivering score stack not as bazel modules but as a set of precompiled binaries.
While both are clear benefits in my opinion I would say that the first benefit is the major one.
I don't see why we would expose all these implementation details as part of the API if we can avoid it.
I would say the cost of code duplication is rather small here, compared to the benefit.
| /// @brief Reports an occurrence of a Checkpoint | ||
| /// @param [in] f_checkpointId Checkpoint identifier. | ||
| void ReportCheckpoint(Checkpoint f_checkpointId) const noexcept(true); | ||
| void ReportCheckpoint(std::uint32_t f_checkpointId) const noexcept(true); |
There was a problem hiding this comment.
Two things: First i dont see any beenfit having Alive and AliveImpl. Seconds is that Impl provides an extended interface (checkpoint id instead just alive notification), why?
There was a problem hiding this comment.
Most of the implementation still deals with checkpoints.
I started removing this from the public API as a first step. The rest of the code is yet to be simplified. I did not want to propagate this change here as it would result in massive amount of changes.
But of course you are right, there numbered checkpoint is already obsolete when there is only an alive notification
There was a problem hiding this comment.
so shall we link some ticket for cleanu p ?
|
FT-Team meeting: 2026-06-10: The report_health_status api shall also provide the possibility to report "not ok" state to shorten FTTI times in some use-cases. |
Okay understood. Then I guess the C++ API would look like this: enum class HealthStatus : uint8_t {
kOk,
kNotOk
};
class Alive {
public:
void ReportHealthStatus(HealthStatus status);
};Though I am also wondering if having a separate method for the failure reporting would be more explicit. class Alive {
public:
void ReportAlive();
void ReportFailure();
};What do you think @pawelrutkaq @ramceb ? |
7a78c98 to
677968a
Compare
|
For me,no matter if enum or static names. Just lets dont have two interfaces for the same ;) |
| @@ -0,0 +1,89 @@ | |||
| /******************************************************************************** | |||
There was a problem hiding this comment.
file name lower case, other upper case ?
There was a problem hiding this comment.
The other public APIs in launch manager are all with lower case.
So now it is consistent at least to the outside.
We'll have to adapt the private code later
| void score_lcm_alive_report_failure(void* instance) noexcept; | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
There was a problem hiding this comment.
this does not need to be part of header or ? can be in cpp ?
There was a problem hiding this comment.
you are right, I removed it from the header. Seems enough to have this in the cpp file.
|
|
||
| void Alive::ReportFailure() const noexcept | ||
| { | ||
| // Not implemented |
There was a problem hiding this comment.
I added an assertion that fails when this method is called.
|
|
||
| void score_lcm_alive_report_failure(void* instance) noexcept { | ||
| static_cast<score::mw::lifecycle::Alive*>(instance)->ReportFailure(); | ||
| } |
There was a problem hiding this comment.
missing nullptr checks
There was a problem hiding this comment.
Not sure what should be the behavior in case nullptr is passed, this would always be a programming error.
Silently ignoring the nullptr, might hide such programming errors.
I introduced now the baselibs assert macros as nullptr check.
* Introduce nullptr asserts * For non-implement method ReportFailure(), use assert rather than deprecation warning. * Remove C functions from header file. Seems enough to have them in the cpp file
| { | ||
| } | ||
|
|
||
| Alive::Alive(Alive&& se) noexcept : |
There was a problem hiding this comment.
I think this move constructor and move assignment can just be = default
There was a problem hiding this comment.
Did a grep for Monitor and found the following that might need to be updated:
- ./score/launch_manager/daemon/src/alive_monitor/details/factory/FlatCfgFactory.cpp:93 - log mentions health monitor
- ./score/launch_manager/alive/src/details/AliveImpl.h:28 - the brief should be updated
Refactors the Launch Manager "Monitor" interface to the Alive API.
Example usage:
Public bazel targets:
//score/launch_manager:alive_cc//score/launch_manager:alive_rustChanges:
Open Questions:
Closes: #149