Skip to content

Commit babfad0

Browse files
al1imgmlohvynenko
authored andcommitted
sm: launcher: add launcher design document and base interfaces
Signed-off-by: Oleksandr Grytsov <[email protected]>
1 parent 5889bc1 commit babfad0

File tree

10 files changed

+530
-1
lines changed

10 files changed

+530
-1
lines changed

src/core/sm/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set(HEADERS config.hpp)
1717
# Install targets
1818
# ######################################################################################################################
1919

20-
set(INSTALL_HEADERS aos_core_sm_logprovider aos_core_sm_runner)
20+
set(INSTALL_HEADERS aos_core_sm_launcher aos_core_sm_logprovider aos_core_sm_runner)
2121

2222
set(INSTALL_LIBRARIES)
2323

@@ -42,6 +42,7 @@ set(TARGET_PREFIX ${TARGET_PREFIX}_sm)
4242
# Subdirectories
4343
# ######################################################################################################################
4444

45+
add_subdirectory(launcher)
4546
add_subdirectory(logprovider)
4647
add_subdirectory(networkmanager)
4748
add_subdirectory(runner)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (C) 2025 EPAM Systems, Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
# ######################################################################################################################
8+
# Target name
9+
# ######################################################################################################################
10+
11+
set(TARGET_NAME launcher)
12+
13+
# ######################################################################################################################
14+
# Headers
15+
# ######################################################################################################################
16+
17+
set(HEADERS itf/instancestatusreceiver.hpp itf/instancestatussender.hpp itf/launcher.hpp itf/runtime.hpp
18+
itf/storage.hpp
19+
)
20+
21+
# ######################################################################################################################
22+
# Target
23+
# ######################################################################################################################
24+
25+
add_module(TARGET_NAME ${TARGET_NAME} HEADERS ${HEADERS})
26+
27+
# ######################################################################################################################
28+
# Tests
29+
# ######################################################################################################################
30+
31+
if(WITH_TEST)
32+
add_subdirectory(tests)
33+
endif()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_SM_LAUNCHER_ITF_INSTANCESTATUSRECEIVER_HPP_
8+
#define AOS_CORE_SM_LAUNCHER_ITF_INSTANCESTATUSRECEIVER_HPP_
9+
10+
#include <core/common/types/instance.hpp>
11+
12+
namespace aos::sm::launcher {
13+
14+
/** @addtogroup sm Service Manager
15+
* @{
16+
*/
17+
18+
/**
19+
* Receives instance status updates.
20+
*/
21+
class InstanceStatusReceiverItf {
22+
public:
23+
/**
24+
* Destructor.
25+
*/
26+
virtual ~InstanceStatusReceiverItf() = default;
27+
28+
/**
29+
* Receives instance status.
30+
*
31+
* @param status instance status.
32+
* @return Error.
33+
*/
34+
virtual Error OnInstanceStatusReceived(const Array<InstanceStatus>& statuses) = 0;
35+
};
36+
37+
} // namespace aos::sm::launcher
38+
39+
#endif
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_SM_LAUNCHER_ITF_INSTANCESTATUSSENDER_HPP_
8+
#define AOS_CORE_SM_LAUNCHER_ITF_INSTANCESTATUSSENDER_HPP_
9+
10+
#include <core/common/types/instance.hpp>
11+
12+
namespace aos::sm::launcher {
13+
14+
/** @addtogroup sm Service Manager
15+
* @{
16+
*/
17+
18+
/**
19+
* Instance status sender interface.
20+
*/
21+
class InstanceStatusSenderItf {
22+
public:
23+
/**
24+
* Destructor.
25+
*/
26+
virtual ~InstanceStatusSenderItf() = default;
27+
28+
/**
29+
* Sends node instances statuses.
30+
*
31+
* @param statuses instances statuses.
32+
*/
33+
virtual void SendNodeInstancesStatuses(const Array<aos::InstanceStatus>& statuses) = 0;
34+
35+
/**
36+
* Sends update instances statuses.
37+
*
38+
* @param statuses instances statuses.
39+
*/
40+
virtual void SendUpdateInstancesStatuses(const Array<aos::InstanceStatus>& statuses) = 0;
41+
};
42+
43+
/** @}*/
44+
45+
} // namespace aos::sm::launcher
46+
47+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_SM_LAUNCHER_ITF_LAUNCHER_HPP_
8+
#define AOS_CORE_SM_LAUNCHER_ITF_LAUNCHER_HPP_
9+
10+
#include <core/common/types/common.hpp>
11+
12+
namespace aos::sm::launcher {
13+
14+
/** @addtogroup sm Service Manager
15+
* @{
16+
*/
17+
18+
/**
19+
* Launcher interface.
20+
*/
21+
class LauncherItf {
22+
public:
23+
/**
24+
* Destructor.
25+
*/
26+
virtual ~LauncherItf() = default;
27+
28+
/**
29+
* Update running instances.
30+
*
31+
* @param stopInstances instances to stop.
32+
* @param startInstances instances to start.
33+
* @return Error.
34+
*/
35+
virtual Error UpdateInstances(const Array<InstanceIdent>& stopInstances, const Array<InstanceInfo>& startInstances)
36+
= 0;
37+
};
38+
39+
/** @}*/
40+
41+
} // namespace aos::sm::launcher
42+
43+
#endif
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_SM_LAUNCHER_ITF_RUNTIME_HPP_
8+
#define AOS_CORE_SM_LAUNCHER_ITF_RUNTIME_HPP_
9+
10+
#include <core/common/monitoring/itf/instancemonitoringprovider.hpp>
11+
12+
namespace aos::sm::launcher {
13+
14+
/** @addtogroup sm Service Manager
15+
* @{
16+
*/
17+
18+
/**
19+
* Runtime interface.
20+
*/
21+
class RuntimeItf : public monitoring::InstanceMonitoringProviderItf {
22+
public:
23+
/**
24+
* Destructor.
25+
*/
26+
virtual ~RuntimeItf() = default;
27+
28+
/**
29+
* Starts runtime.
30+
*
31+
* @return Error.
32+
*/
33+
virtual Error Start() = 0;
34+
35+
/**
36+
* Stops runtime.
37+
*
38+
* @return Error.
39+
*/
40+
virtual Error Stop() = 0;
41+
42+
/**
43+
* Returns runtime info.
44+
*
45+
* @param[out] runtimeInfo runtime info.
46+
* @return Error.
47+
*/
48+
virtual Error GetInfo(RuntimeInfo& runtimeInfo) const = 0;
49+
50+
/**
51+
* Start instance.
52+
*
53+
* @param instance instance to start.
54+
* @param[out] status instance status.
55+
* @return Error.
56+
*/
57+
virtual Error StartInstance(const InstanceInfo& instance, InstanceStatus& status) = 0;
58+
59+
/**
60+
* Stop instance.
61+
*
62+
* @param instance instance to stop.
63+
* @param[out] status instance status.
64+
* @return Error.
65+
*/
66+
virtual Error StopInstance(const InstanceIdent& instance, InstanceStatus& status) = 0;
67+
};
68+
69+
/**
70+
* Runtime factory interface.
71+
*/
72+
class RuntimeFactoryItf {
73+
public:
74+
/**
75+
* Destructor.
76+
*/
77+
virtual ~RuntimeFactoryItf() = default;
78+
79+
/**
80+
* Creates runtime from runtime info.
81+
*
82+
* @param runtimeInfo runtime info.
83+
* @param[out] runtime created runtime.
84+
* @return Error.
85+
*/
86+
virtual Error CreateRuntime(const RuntimeInfo& runtimeInfo, RuntimeItf& runtime) = 0;
87+
};
88+
89+
/** @} */
90+
91+
} // namespace aos::sm::launcher
92+
93+
#endif
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (C) 2025 EPAM Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef AOS_CORE_SM_LAUNCHER_ITF_STORAGE_HPP_
8+
#define AOS_CORE_SM_LAUNCHER_ITF_STORAGE_HPP_
9+
10+
#include <core/common/monitoring/itf/instanceparamsprovider.hpp>
11+
#include <core/common/types/instance.hpp>
12+
13+
namespace aos::sm::launcher {
14+
15+
/**
16+
* Launcher storage interface.
17+
*/
18+
class StorageItf {
19+
public:
20+
/**
21+
* Destructor.
22+
*/
23+
virtual ~StorageItf() = default;
24+
25+
/**
26+
* Gets all instance infos from storage.
27+
*
28+
* @param[out] infos array to store instance infos.
29+
* @return Error.
30+
*/
31+
virtual Error GetAllInstanceInfos(Array<InstanceInfo>& infos) = 0;
32+
33+
/**
34+
* Stores instance info to storage.
35+
*
36+
* @param info instance info to store.
37+
* @return Error.
38+
*/
39+
virtual Error AddInstanceInfo(const InstanceInfo& info) = 0;
40+
41+
/**
42+
* Deletes instance info from storage.
43+
*
44+
* @param instanceIdent instance ident.
45+
* @return Error.
46+
*/
47+
virtual Error RemoveInstanceInfo(const InstanceIdent& ident) = 0;
48+
};
49+
50+
/** @}*/
51+
52+
} // namespace aos::sm::launcher
53+
54+
#endif

0 commit comments

Comments
 (0)