-
Notifications
You must be signed in to change notification settings - Fork 25
Refactor Monitor API to public Alive API #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NicolasFussberger
merged 21 commits into
eclipse-score:main
from
etas-contrib:feature/rename-monitor-to-alive
Jun 22, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9a8d537
Rename Monitor to Alive API
NicolasFussberger 19481b5
Make MonitorImplWrapper private
NicolasFussberger 6aa3aa2
Remove instanceSpecifier from Alive API
NicolasFussberger 49772b1
Remove obsolete MonitorImplWrapper class
NicolasFussberger 8ff7a2c
Rename rust binding for Alive API
NicolasFussberger ab0ce3d
Further renaming
NicolasFussberger 8a7be45
Move Alive API to launch_manager/alive
NicolasFussberger 03bdf1b
Remove checkpoint ids from public API
NicolasFussberger 6c177e1
Cleanup doxygen
NicolasFussberger 3ee753c
Fix bazel formatting
NicolasFussberger 447d12d
Correct cargo files
NicolasFussberger 31db29a
Add doxygen documentation
NicolasFussberger 2278cde
Update copyright header
NicolasFussberger a338ba9
Add ReportFailure method
NicolasFussberger 677968a
Correct name in log message
NicolasFussberger 3d0954a
Fixes for Alive API
NicolasFussberger e3b62de
Merge remote-tracking branch 'upstream/main' into feature/rename-moni…
NicolasFussberger c7019a4
Default move ctor and assignment
NicolasFussberger 0fe8760
More renaming Monitor -> Alive
NicolasFussberger d87cb5b
Merge remote-tracking branch 'upstream/main' into feature/rename-moni…
NicolasFussberger 16959c4
Merge branch 'main' into feature/rename-monitor-to-alive
NicolasFussberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
|
||
| cc_library( | ||
| name = "alive", | ||
| srcs = [ | ||
| "src/alive.cpp", | ||
| ], | ||
| hdrs = [ | ||
| "src/alive.h", | ||
| ], | ||
| include_prefix = "score/mw/lifecycle", | ||
| strip_include_prefix = "/score/launch_manager/src/alive/src", | ||
| visibility = ["//score:__subpackages__"], | ||
| deps = [ | ||
| "//score/launch_manager/src/alive/src/details:alive_impl", | ||
| "@score_baselibs//score/language/futurecpp", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
|
|
||
| #include "score/mw/lifecycle/alive.h" | ||
| #include "score/mw/launch_manager/alive_monitor/details/AliveImpl.h" | ||
|
|
||
| #include <utility> | ||
| #include <cassert> | ||
|
|
||
| // The public API is only sending alive notification. No need to support different checkpoints. | ||
| static constexpr std::uint32_t kDefaultCheckpointId{1U}; | ||
|
|
||
| namespace score::mw::lifecycle | ||
| { | ||
|
|
||
| Alive::Alive(const std::string_view& instance) noexcept(false) : | ||
| aliveImplPtr(std::make_unique<AliveImpl>(instance)) | ||
| { | ||
| } | ||
|
|
||
| Alive::Alive(Alive&& se) noexcept = default; | ||
|
|
||
| Alive& Alive::operator=(Alive&& se) noexcept = default; | ||
|
|
||
| Alive::~Alive() noexcept = default; | ||
|
|
||
| void Alive::ReportAlive() const noexcept | ||
| { | ||
| if (aliveImplPtr.get() != nullptr) | ||
| { | ||
| aliveImplPtr->ReportCheckpoint(kDefaultCheckpointId); | ||
| } | ||
| } | ||
|
|
||
| void Alive::ReportFailure() const noexcept | ||
| { | ||
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(false, "Alive::ReportFailure() is not yet implemented"); | ||
| } | ||
|
|
||
| } // namespace score::mw::lifecycle | ||
|
|
||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| void* score_lcm_alive_initialize(const char* instanceSpecifier) noexcept { | ||
| if(instanceSpecifier == nullptr) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| try { | ||
| auto* alivePtr = new score::mw::lifecycle::Alive(instanceSpecifier); | ||
| return static_cast<void*>(alivePtr); | ||
| } catch (...) { | ||
| return nullptr; | ||
| } | ||
| } | ||
|
|
||
| void score_lcm_alive_deinitialize(void* instance) noexcept { | ||
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION(instance != nullptr); | ||
| auto* alivePtr = static_cast<score::mw::lifecycle::Alive*>(instance); | ||
| delete alivePtr; | ||
| } | ||
|
|
||
| void score_lcm_alive_report_alive(void* instance) noexcept { | ||
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION(instance != nullptr); | ||
| static_cast<score::mw::lifecycle::Alive*>(instance)->ReportAlive(); | ||
| } | ||
|
|
||
| void score_lcm_alive_report_failure(void* instance) noexcept { | ||
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION(instance != nullptr); | ||
| static_cast<score::mw::lifecycle::Alive*>(instance)->ReportFailure(); | ||
| } | ||
|
pawelrutkaq marked this conversation as resolved.
|
||
|
|
||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
NicolasFussberger marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /******************************************************************************** | ||
|
pawelrutkaq marked this conversation as resolved.
|
||
| * Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
|
|
||
| #ifndef SCORE_LCM_ALIVE_H_ | ||
| #define SCORE_LCM_ALIVE_H_ | ||
|
|
||
| #include <cstdint> | ||
| #include <memory> | ||
| #include <string_view> | ||
|
|
||
| namespace score::mw::lifecycle | ||
| { | ||
|
|
||
| // Forward declaration | ||
| class AliveImpl; | ||
|
|
||
| /// @brief Alive API for reporting alive notifications to the launch manager. | ||
| /// An alive notification indicates that the component is still active and functioning correctly. | ||
| /// The launch manager is configured with an expected alive notification interval, | ||
| /// and if it does not receive an alive notification within that interval, | ||
| /// it executes the configured recovery action. | ||
| /// | ||
| /// Each process may only use a single Alive instance. | ||
| class Alive | ||
| { | ||
| public: | ||
| /// @brief Creation of an Alive. | ||
| /// @param [in] instance Instance specifier (currently unused) | ||
| /// @throws std::runtime_error if the configured IPC channel to connect to launch manager is not existing | ||
| /// @throws std::bad_alloc in case of insufficient memory | ||
| explicit Alive(const std::string_view& instance) noexcept(false); | ||
|
|
||
| /// @brief The copy constructor for Alive shall not be used. | ||
| Alive(const Alive& se) = delete; | ||
|
|
||
| /// @brief Move constructor for Alive | ||
| /// @param [in,out] se The Alive object to be moved | ||
| Alive(Alive&& se) noexcept; | ||
|
|
||
| /// @brief The copy assignment operator for Alive shall not be used. | ||
| Alive& operator=(const Alive& se) = delete; | ||
|
|
||
| /// @brief Move assignment operator for Alive | ||
| /// @param [in,out] se The Alive object to be moved | ||
| /// @return The moved Alive object | ||
| Alive& operator=(Alive&& se) noexcept; | ||
|
|
||
| /// @brief Destructor of an Alive | ||
| virtual ~Alive() noexcept; | ||
|
|
||
| /// @brief Reports an alive notification | ||
| /// @remark Thread safety: This method is NOT thread safe. | ||
| void ReportAlive() const noexcept; | ||
|
|
||
| /// @brief Report a direct failure | ||
| /// @remark Thread safety: This method is NOT thread safe. | ||
| /// @note Not Implemented. This method currently does nothing. | ||
| void ReportFailure() const noexcept; | ||
|
|
||
| private: | ||
| /// @brief Unique pointer to implementation class of Alive | ||
| std::unique_ptr<AliveImpl> aliveImplPtr; | ||
|
NicolasFussberger marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| } // namespace score::mw::lifecycle | ||
| #endif // SCORE_LCM_ALIVE_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.