89ff7c0bd5c89b84598e93eff189ee53cb5bd45b
[ric-plt/sdl.git] / include / private / redis / asynchiredisdatabasediscovery.hpp
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 #ifndef SHAREDDATALAYER_REDIS_ASYNCHIREDISDATABASEDISCOVERY_HPP_
18 #define SHAREDDATALAYER_REDIS_ASYNCHIREDISDATABASEDISCOVERY_HPP_
19
20 #include "private/redis/asyncdatabasediscovery.hpp"
21 #include "private/redis/databaseinfo.hpp"
22 #include "private/databaseconfiguration.hpp"
23 #include "private/logger.hpp"
24 #include <string>
25 #include <memory>
26
27 namespace shareddatalayer
28 {
29     class Engine;
30
31     namespace redis
32     {
33         class AsyncHiredisDatabaseDiscovery: public AsyncDatabaseDiscovery
34         {
35         public:
36             AsyncHiredisDatabaseDiscovery(const AsyncHiredisDatabaseDiscovery&) = delete;
37
38             AsyncHiredisDatabaseDiscovery& operator = (const AsyncHiredisDatabaseDiscovery&) = delete;
39
40             AsyncHiredisDatabaseDiscovery(std::shared_ptr<Engine> engine,
41                                           const boost::optional<std::string>& ns,
42                                           DatabaseInfo::Type databaseType,
43                                           const DatabaseConfiguration::Addresses& databaseAddresses,
44                                           std::shared_ptr<Logger> logger);
45
46             ~AsyncHiredisDatabaseDiscovery() override = default;
47
48             // Note: Current implementation does not monitor possible cluster configuration changes.
49             void setStateChangedCb(const StateChangedCb& stateChangedCb) override;
50
51             void clearStateChangedCb() override;
52
53             void setConnected(bool state);
54
55         private:
56             std::shared_ptr<Engine> engine;
57             const boost::optional<std::string> ns;
58             const DatabaseInfo::Type databaseType;
59             const DatabaseConfiguration::Addresses databaseAddresses;
60             std::shared_ptr<Logger> logger;
61         };
62     }
63 }
64
65 #endif