RIC:1060: Change in PTL
[ric-plt/sdl.git] / src / redis / asynchiredisdatabasediscovery.cpp
1 /*
2    Copyright (c) 2018-2019 Nokia.
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 */
16
17 /*
18  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19  * platform project (RICP).
20 */
21
22 #include "private/asyncconnection.hpp"
23 #include "private/redis/asynchiredisdatabasediscovery.hpp"
24 #include "private/engine.hpp"
25 #include "private/logger.hpp"
26 #include "private/redis/asynccommanddispatcher.hpp"
27 #include "private/redis/contentsbuilder.hpp"
28
29 using namespace shareddatalayer;
30 using namespace shareddatalayer::redis;
31
32 AsyncHiredisDatabaseDiscovery::AsyncHiredisDatabaseDiscovery(std::shared_ptr<Engine> engine,
33                                                              const boost::optional<std::string>& ns,
34                                                              DatabaseInfo::Type databaseType,
35                                                              const DatabaseConfiguration::Addresses& databaseAddresses,
36                                                              std::shared_ptr<Logger> logger):
37     engine(engine),
38     ns(ns),
39     databaseType(databaseType),
40     databaseAddresses(databaseAddresses),
41     logger(logger)
42 {
43 }
44
45 void AsyncHiredisDatabaseDiscovery::setStateChangedCb(const StateChangedCb& stateChangedCb)
46 {
47     /* Note: Current implementation does not monitor possible database configuration changes.
48      * If that is needed, we would probably need to monitor json configuration file changes.
49      */
50     const DatabaseInfo databaseInfo = { databaseAddresses, databaseType, ns, DatabaseInfo::Discovery::HIREDIS };
51     engine->postCallback(std::bind(stateChangedCb,
52                                    databaseInfo));
53 }
54
55 void AsyncHiredisDatabaseDiscovery::clearStateChangedCb()
56 {
57 }