Skip to content

Commit 2e7904b

Browse files
authored
Feature/SE integration (#26)
* SE inited ---------
1 parent e98b02b commit 2e7904b

50 files changed

Lines changed: 2224 additions & 36 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
.idea
3636

3737
/build
38+
/build-ex
3839
/cmake-build-*
3940

4041
/.build
4142
/.venv
4243
/.vcpkg
4344
/.build*
45+
/vcpkg_installed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
18+
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API ON)
1819

1920
project(cpp-jam
2021
VERSION 0.0.1
@@ -75,6 +76,12 @@ find_package(Boost.DI CONFIG REQUIRED)
7576
find_package(qtils CONFIG REQUIRED)
7677
find_package(prometheus-cpp CONFIG REQUIRED)
7778

79+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
80+
add_compile_options(-fmodules-ts)
81+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
82+
add_compile_options(-fmodules)
83+
endif()
84+
7885
add_library(headers INTERFACE)
7986
target_include_directories(headers INTERFACE
8087
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src_>

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ add_subdirectory(metrics)
2424
# Clocks and time subsystem
2525
add_subdirectory(clock)
2626

27+
# Subscription Engine subsystem
28+
add_subdirectory(se)
29+
30+
# Modules subsystem
31+
add_subdirectory(modules)

src/app/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ add_library(build_version
2828

2929
add_library(app_configuration SHARED configuration.cpp)
3030
target_link_libraries(app_configuration
31-
Boost::boost)
31+
Boost::boost
32+
fmt::fmt
33+
)
3234

3335
add_library(app_configurator SHARED configurator.cpp)
3436
target_link_libraries(app_configurator

src/app/configuration.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#pragma once
77

8+
#include <filesystem>
89
#include <string>
910

1011
#include <boost/asio/ip/tcp.hpp>
@@ -22,6 +23,7 @@ namespace jam::app {
2223

2324
[[nodiscard]] std::string nodeVersion() const;
2425
[[nodiscard]] std::string nodeName() const;
26+
2527
[[nodiscard]] std::optional<Endpoint> metricsEndpoint() const;
2628

2729
private:

src/app/configurator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include "app/configuration.hpp"
6+
#include "app/configurator.hpp"
77

88
#include <filesystem>
99
#include <iostream>
1010

1111
#include <boost/asio/ip/tcp.hpp>
12+
#include <boost/beast/core/error.hpp>
1213
#include <boost/program_options.hpp>
1314
#include <boost/program_options/value_semantic.hpp>
1415
#include <qtils/outcome.hpp>
1516

1617
#include "app/build_version.hpp"
17-
#include "app/configurator.hpp"
18-
19-
#include <boost/beast/core/error.hpp>
18+
#include "app/configuration.hpp"
2019

2120
using Endpoint = boost::asio::ip::tcp::endpoint;
2221

@@ -110,7 +109,7 @@ namespace jam::app {
110109
.add(metrics_options);
111110
}
112111

113-
outcome::result<bool> Configurator::step1() {
112+
outcome::result<bool> Configurator::step1() { // read min cli-args and config
114113
namespace po = boost::program_options;
115114
namespace fs = std::filesystem;
116115

@@ -120,7 +119,7 @@ namespace jam::app {
120119

121120
po::variables_map vm;
122121

123-
// first-run parse to read only general options and to lookup for "help",
122+
// first-run parse to read-only general options and to lookup for "help",
124123
// "config" and "version". all the rest options are ignored
125124
try {
126125
po::parsed_options parsed = po::command_line_parser(argc_, argv_)
@@ -200,6 +199,7 @@ namespace jam::app {
200199
}
201200

202201
outcome::result<void> Configurator::initGeneralConfig() {
202+
// Init by config-file
203203
if (config_file_.has_value()) {
204204
auto section = (*config_file_)["general"];
205205
if (section.IsDefined()) {

src/app/configurator.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#pragma once
77

8+
#include <optional>
9+
810
#include <boost/program_options.hpp>
911
#include <qtils/enum_error_code.hpp>
1012
#include <qtils/outcome.hpp>

src/app/impl/application_impl.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@
1616
#include "log/logger.hpp"
1717
#include "metrics/histogram_timer.hpp"
1818
#include "metrics/metrics.hpp"
19+
#include "se/impl/subscription_manager.hpp"
1920

2021
namespace jam::app {
2122

23+
SeHolder::SeHolder(SePtr se) : se_(std::move(se)) {}
24+
25+
SeHolder::~SeHolder() {
26+
se_->dispose();
27+
}
28+
2229
ApplicationImpl::ApplicationImpl(
2330
std::shared_ptr<log::LoggingSystem> logsys,
2431
std::shared_ptr<Configuration> config,
2532
std::shared_ptr<StateManager> state_manager,
2633
std::shared_ptr<Watchdog> watchdog,
2734
std::shared_ptr<metrics::Exposer> metrics_exposer,
28-
std::shared_ptr<clock::SystemClock> system_clock)
35+
std::shared_ptr<clock::SystemClock> system_clock,
36+
std::shared_ptr<SeHolder>)
2937
: logger_(logsys->getLogger("Application", "application")),
3038
app_config_(std::move(config)),
3139
state_manager_(std::move(state_manager)),

src/app/impl/application_impl.hpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
#pragma once
88

9-
#include "app/application.hpp"
10-
119
#include <memory>
1210

1311
#include <metrics/registry.hpp>
1412

13+
#include "app/application.hpp"
14+
#include "se/subscription_fwd.hpp"
15+
1516
namespace jam {
1617
class Watchdog;
1718
} // namespace jam
@@ -41,14 +42,46 @@ namespace jam::metrics {
4142

4243
namespace jam::app {
4344

45+
/**
46+
* @brief RAII holder for subscription engine management
47+
*
48+
* SeHolder is responsible for managing the lifetime of subscription engine
49+
* components. It ensures proper initialization and cleanup of the
50+
* subscription system during application lifecycle.
51+
*/
52+
struct SeHolder final {
53+
using SePtr = std::shared_ptr<Subscription>;
54+
SePtr se_;
55+
56+
// Disable copying - subscription engine should not be copied
57+
SeHolder(const SeHolder &) = delete;
58+
SeHolder &operator=(const SeHolder &) = delete;
59+
60+
// Disable moving - subscription engine should not be moved
61+
SeHolder(SeHolder &&) = delete;
62+
SeHolder &operator=(SeHolder &&) = delete;
63+
64+
/**
65+
* @brief Constructs SeHolder with subscription engine instance
66+
* @param se Shared pointer to subscription engine
67+
*/
68+
SeHolder(SePtr se);
69+
70+
/**
71+
* @brief Destructor ensures proper cleanup of subscription engine
72+
*/
73+
~SeHolder();
74+
};
75+
4476
class ApplicationImpl final : public Application {
4577
public:
4678
ApplicationImpl(std::shared_ptr<log::LoggingSystem> logsys,
4779
std::shared_ptr<Configuration> config,
4880
std::shared_ptr<StateManager> state_manager,
4981
std::shared_ptr<Watchdog> watchdog,
5082
std::shared_ptr<metrics::Exposer> metrics_exposer,
51-
std::shared_ptr<clock::SystemClock> system_clock);
83+
std::shared_ptr<clock::SystemClock> system_clock,
84+
std::shared_ptr<SeHolder>);
5285

5386
void run() override;
5487

src/app/impl/state_manager_impl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
#pragma once
88

9-
#include "app/state_manager.hpp"
10-
119
#include <condition_variable>
1210
#include <csignal>
1311
#include <mutex>
1412
#include <queue>
1513

14+
#include "app/state_manager.hpp"
1615
#include "utils/ctor_limiters.hpp"
1716

1817
namespace soralog {

0 commit comments

Comments
 (0)