Skip to content
Merged
Show file tree
Hide file tree
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 Jun 5, 2026
19481b5
Make MonitorImplWrapper private
NicolasFussberger Jun 5, 2026
6aa3aa2
Remove instanceSpecifier from Alive API
NicolasFussberger Jun 5, 2026
49772b1
Remove obsolete MonitorImplWrapper class
NicolasFussberger Jun 5, 2026
8ff7a2c
Rename rust binding for Alive API
NicolasFussberger Jun 5, 2026
ab0ce3d
Further renaming
NicolasFussberger Jun 5, 2026
8a7be45
Move Alive API to launch_manager/alive
NicolasFussberger Jun 5, 2026
03bdf1b
Remove checkpoint ids from public API
NicolasFussberger Jun 5, 2026
6c177e1
Cleanup doxygen
NicolasFussberger Jun 5, 2026
3ee753c
Fix bazel formatting
NicolasFussberger Jun 5, 2026
447d12d
Correct cargo files
NicolasFussberger Jun 5, 2026
31db29a
Add doxygen documentation
NicolasFussberger Jun 8, 2026
2278cde
Update copyright header
NicolasFussberger Jun 8, 2026
a338ba9
Add ReportFailure method
NicolasFussberger Jun 11, 2026
677968a
Correct name in log message
NicolasFussberger Jun 11, 2026
3d0954a
Fixes for Alive API
NicolasFussberger Jun 16, 2026
e3b62de
Merge remote-tracking branch 'upstream/main' into feature/rename-moni…
NicolasFussberger Jun 18, 2026
c7019a4
Default move ctor and assignment
NicolasFussberger Jun 18, 2026
0fe8760
More renaming Monitor -> Alive
NicolasFussberger Jun 18, 2026
d87cb5b
Merge remote-tracking branch 'upstream/main' into feature/rename-moni…
NicolasFussberger Jun 22, 2026
16959c4
Merge branch 'main' into feature/rename-monitor-to-alive
NicolasFussberger Jun 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resolver = "2"
members = [
"score/launch_manager/src/lifecycle_client/src/rust",
"score/launch_manager/src/daemon/src/alive_monitor/rust",
"score/launch_manager/src/alive/src/rust",
"score/health_monitor/src",
"examples/rust_supervised_app",
]
Expand All @@ -19,7 +19,7 @@ libc = "0.2.177"
clap = { version = "4.5.49", features = ["derive"] }
signal-hook = "0.3.18"

monitor_rs = { path = "score/launch_manager/src/daemon/src/alive_monitor/rust" } # Temporary API
alive_rs = { path = "score/launch_manager/src/alive/src/rust" } # Temporary API
health_monitoring_lib = { path = "score/health_monitor/src" }
score_log = { git = "https://github.com/eclipse-score/baselibs_rust.git", tag = "v0.1.1" }
score_testing_macros = { git = "https://github.com/eclipse-score/baselibs_rust.git", tag = "v0.1.1" }
Expand Down
1 change: 0 additions & 1 deletion examples/cpp_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ cc_binary(
visibility = ["//visibility:public"],
deps = [
"//score/health_monitor:health_monitoring_cc",
"//score/launch_manager:alive_cc",
"//score/launch_manager:lifecycle_cc",
"@score_baselibs_rust//src/log/stdout_logger_cpp_init",
],
Expand Down
2 changes: 1 addition & 1 deletion examples/rust_supervised_app/Cargo.toml
Comment thread
NicolasFussberger marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ clap = { workspace = true }
libc = { workspace = true }
signal-hook = { workspace = true }
lifecycle_client_rs = { path = "../../score/launch_manager/src/lifecycle_client/src/rust" }
monitor_rs = { path = "../../score/launch_manager/src/daemon/src/alive_monitor/rust" }
alive_rs = { path = "../../score/launch_manager/src/alive/src/rust" }
health_monitoring_lib.workspace = true
score_log.workspace = true
stdout_logger.workspace = true
4 changes: 2 additions & 2 deletions score/health_monitor/src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ thread.workspace = true
score_log.workspace = true
score_testing_macros.workspace = true
containers.workspace = true
monitor_rs = { workspace = true, optional = true }
alive_rs = { workspace = true, optional = true }
Comment thread
NicolasFussberger marked this conversation as resolved.

[dev-dependencies]
stdout_logger.workspace = true
Expand All @@ -27,5 +27,5 @@ stdout_logger.workspace = true
loom = { version = "0.7.2", features = ["checkpoint"] }

[features]
default = ["monitor_rs"]
default = ["alive_rs"]
stub_supervisor_api_client = []
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

use crate::log::debug;
use crate::supervisor_api_client::SupervisorAPIClient;
use crate::worker::Checks;

pub struct ScoreSupervisorAPIClient {
supervisor_link: monitor_rs::Monitor<Checks>,
supervisor_link: alive_rs::Alive,
}

unsafe impl Send for ScoreSupervisorAPIClient {} // Just assuming it's safe to send across threads, this is a temporary solution
Expand All @@ -28,13 +27,13 @@ impl ScoreSupervisorAPIClient {
let value = std::env::var("IDENTIFIER").expect("IDENTIFIER env not set");
debug!("ScoreSupervisorAPIClient: Creating with IDENTIFIER={}", value);
// This is only temporary usage so unwrap is fine here.
let supervisor_link = monitor_rs::Monitor::<Checks>::new(&value).expect("Failed to create supervisor_link");
let supervisor_link = alive_rs::Alive::new(&value).expect("Failed to create supervisor_link");
Self { supervisor_link }
}
}

impl SupervisorAPIClient for ScoreSupervisorAPIClient {
fn notify_alive(&self) {
self.supervisor_link.report_checkpoint(Checks::WorkerCheckpoint);
self.supervisor_link.report_alive();
}
}
4 changes: 2 additions & 2 deletions score/launch_manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ alias(

alias(
name = "alive_cc",
actual = "//score/launch_manager/src/daemon/src/alive_monitor:am_shared_lib",
actual = "//score/launch_manager/src/alive:alive",
)

alias(
name = "alive_rust",
actual = "//score/launch_manager/src/daemon/src/alive_monitor/rust:monitor_rs",
actual = "//score/launch_manager/src/alive/src/rust:alive_rs",
)

alias(
Expand Down
30 changes: 30 additions & 0 deletions score/launch_manager/src/alive/BUILD
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",
],
)
89 changes: 89 additions & 0 deletions score/launch_manager/src/alive/src/alive.cpp
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();
}
Comment thread
pawelrutkaq marked this conversation as resolved.


#ifdef __cplusplus
}
#endif
76 changes: 76 additions & 0 deletions score/launch_manager/src/alive/src/alive.h
Comment thread
NicolasFussberger marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/********************************************************************************
Comment thread
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;
Comment thread
NicolasFussberger marked this conversation as resolved.
};

} // namespace score::mw::lifecycle
#endif // SCORE_LCM_ALIVE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#include "score/mw/launch_manager/alive_monitor/details/MonitorImpl.h"
#include "score/mw/launch_manager/alive_monitor/details/AliveImpl.h"

#include <unistd.h>

Expand All @@ -22,7 +22,7 @@
namespace score::mw::lifecycle
{

MonitorImpl::MonitorImpl(const std::string_view& f_instanceSpecifier_r,
AliveImpl::AliveImpl(const std::string_view& f_instanceSpecifier_r,
std::unique_ptr<CheckpointIpcClient> f_ipcClient) noexcept(false)
: k_instanceSpecifierPath(f_instanceSpecifier_r),
ipcClient(std::move(f_ipcClient)),
Expand All @@ -33,17 +33,17 @@ MonitorImpl::MonitorImpl(const std::string_view& f_instanceSpecifier_r,
connectToPhmDaemon();
}

void MonitorImpl::ReportCheckpoint(Checkpoint f_checkpointId) const noexcept(true)
void AliveImpl::ReportCheckpoint(std::uint32_t f_checkpointId) const noexcept(true)
{
(void)ipcClient->sendEmplace(score::lcm::saf::timers::OsClock::getMonotonicSystemClock(), f_checkpointId);
}

void MonitorImpl::connectToPhmDaemon(void) noexcept(false)
void AliveImpl::connectToPhmDaemon(void) noexcept(false)
{
const auto ipc_path_res = readInterfacePath();
if (ipc_path_res == std::nullopt)
{
logger_r.LogError() << "Failed to load interface path for Monitor (" << k_instanceSpecifierPath << ")";
logger_r.LogError() << "Failed to load interface path for Alive instance (" << k_instanceSpecifierPath << ")";
throw std::runtime_error("Failed to get interface path");
}
CheckpointIpcClient::EIpcInitResult initResult{ipcClient->init(ipc_path_res.value())};
Expand All @@ -55,13 +55,13 @@ void MonitorImpl::connectToPhmDaemon(void) noexcept(false)
{
const uid_t uid{geteuid()};
logger_r.LogError() << "Connection to PHM daemon failed (permission denied for effective uid" << uid
<< "), for the Monitor (" << k_instanceSpecifierPath << ")";
<< "), for the Alive instance (" << k_instanceSpecifierPath << ")";
return;
}
logger_r.LogError() << "Connection to PHM daemon failed, for the Monitor (" << k_instanceSpecifierPath << ")";
logger_r.LogError() << "Connection to PHM daemon failed, for the Alive instance (" << k_instanceSpecifierPath << ")";
}

std::optional<std::string_view> MonitorImpl::readInterfacePath() noexcept
std::optional<std::string_view> AliveImpl::readInterfacePath() noexcept
{
const char* if_path{getenv("LCM_ALIVE_INTERFACE_PATH")};
if (if_path == nullptr || if_path[0] == '\0')
Expand Down
Loading
Loading