|
6 | 6 |
|
7 | 7 | #pragma once |
8 | 8 |
|
9 | | -#include "app/application.hpp" |
10 | | - |
11 | 9 | #include <memory> |
12 | 10 |
|
13 | 11 | #include <metrics/registry.hpp> |
14 | 12 |
|
| 13 | +#include "app/application.hpp" |
| 14 | +#include "se/subscription_fwd.hpp" |
| 15 | + |
15 | 16 | namespace jam { |
16 | 17 | class Watchdog; |
17 | 18 | } // namespace jam |
@@ -41,14 +42,46 @@ namespace jam::metrics { |
41 | 42 |
|
42 | 43 | namespace jam::app { |
43 | 44 |
|
| 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 | + |
44 | 76 | class ApplicationImpl final : public Application { |
45 | 77 | public: |
46 | 78 | ApplicationImpl(std::shared_ptr<log::LoggingSystem> logsys, |
47 | 79 | std::shared_ptr<Configuration> config, |
48 | 80 | std::shared_ptr<StateManager> state_manager, |
49 | 81 | std::shared_ptr<Watchdog> watchdog, |
50 | 82 | 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>); |
52 | 85 |
|
53 | 86 | void run() override; |
54 | 87 |
|
|
0 commit comments