Add extra line about src files are part of RIC platform project
[ric-plt/sdl.git] / include / private / redis / asyncsentineldatabasediscovery.hpp
index 527fa4e..c471a37 100644 (file)
    limitations under the License.
 */
 
+/*
+ * This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ * platform project (RICP).
+*/
+
 #ifndef SHAREDDATALAYER_REDIS_ASYNCSENTINELDATABASEDISCOVERY_HPP_
 #define SHAREDDATALAYER_REDIS_ASYNCSENTINELDATABASEDISCOVERY_HPP_
 
@@ -44,21 +49,26 @@ namespace shareddatalayer
             using AsyncCommandDispatcherCreator = std::function<std::shared_ptr<redis::AsyncCommandDispatcher>(Engine& engine,
                                                                                                                const redis::DatabaseInfo& databaseInfo,
                                                                                                                std::shared_ptr<redis::ContentsBuilder> contentsBuilder,
-                                                                                                               std::shared_ptr<Logger> logger)>;
+                                                                                                               std::shared_ptr<Logger> logger,
+                                                                                                               bool usePermanentCommandCallbacks)>;
 
             AsyncSentinelDatabaseDiscovery(const AsyncSentinelDatabaseDiscovery&) = delete;
 
             AsyncSentinelDatabaseDiscovery& operator = (const AsyncSentinelDatabaseDiscovery&) = delete;
 
             AsyncSentinelDatabaseDiscovery(std::shared_ptr<Engine> engine,
-                                           std::shared_ptr<Logger> logger);
+                                           std::shared_ptr<Logger> logger,
+                                           const HostAndPort& sentinelAddress,
+                                           const std::string& sentinelMasterName);
 
             AsyncSentinelDatabaseDiscovery(std::shared_ptr<Engine> engine,
                                            std::shared_ptr<Logger> logger,
+                                           const HostAndPort& sentinelAddress,
+                                           const std::string& sentinelMasterName,
                                            const AsyncCommandDispatcherCreator& asyncCommandDispatcherCreator,
                                            std::shared_ptr<redis::ContentsBuilder> contentsBuilder);
 
-            ~AsyncSentinelDatabaseDiscovery() override = default;
+            ~AsyncSentinelDatabaseDiscovery() override;
 
             void setStateChangedCb(const StateChangedCb& stateChangedCb) override;
 
@@ -70,11 +80,19 @@ namespace shareddatalayer
             std::shared_ptr<Logger> logger;
             StateChangedCb stateChangedCb;
             DatabaseInfo databaseInfo;
+            std::string sentinelMasterName;
+            std::shared_ptr<redis::AsyncCommandDispatcher> subscriber;
             std::shared_ptr<redis::AsyncCommandDispatcher> dispatcher;
             std::shared_ptr<redis::ContentsBuilder> contentsBuilder;
+            Timer subscribeRetryTimer;
+            Timer::Duration subscribeRetryTimerDuration;
             Timer masterInquiryRetryTimer;
             Timer::Duration masterInquiryRetryTimerDuration;
 
+            void subscribeNotifications();
+
+            void subscribeAck(const std::error_code& error, const Reply& reply);
+
             void sendMasterInquiry();
 
             void masterInquiryAck(const std::error_code& error, const Reply& reply);