Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 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 | |
Timo Tietavainen | a0745d2 | 2019-11-28 09:55:22 +0200 | [diff] [blame^] | 17 | /* |
| 18 | * This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 19 | * platform project (RICP). |
| 20 | */ |
| 21 | |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 22 | #ifndef SHAREDDATALAYER_REDIS_ASYNCSTORAGEIMPL_HPP_ |
| 23 | #define SHAREDDATALAYER_REDIS_ASYNCSTORAGEIMPL_HPP_ |
| 24 | |
Rolf Badorek | 8324d02 | 2019-09-17 16:47:20 +0300 | [diff] [blame] | 25 | #include <functional> |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 26 | #include <sdl/asyncstorage.hpp> |
| 27 | #include <sdl/publisherid.hpp> |
| 28 | #include "private/configurationreader.hpp" |
| 29 | #include "private/databaseconfigurationimpl.hpp" |
| 30 | #include "private/logger.hpp" |
| 31 | #include "private/namespaceconfigurationsimpl.hpp" |
Rolf Badorek | 8324d02 | 2019-09-17 16:47:20 +0300 | [diff] [blame] | 32 | #include "private/redis/asyncdatabasediscovery.hpp" |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 33 | |
| 34 | namespace shareddatalayer |
| 35 | { |
| 36 | class Engine; |
| 37 | |
| 38 | class AsyncStorageImpl: public AsyncStorage |
| 39 | { |
| 40 | public: |
Rolf Badorek | 8324d02 | 2019-09-17 16:47:20 +0300 | [diff] [blame] | 41 | using AsyncDatabaseDiscoveryCreator = std::function<std::shared_ptr<redis::AsyncDatabaseDiscovery>(std::shared_ptr<Engine> engine, |
| 42 | const DatabaseConfiguration& databaseConfiguration, |
| 43 | std::shared_ptr<Logger> logger)>; |
| 44 | |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 45 | AsyncStorageImpl(const AsyncStorageImpl&) = delete; |
| 46 | |
| 47 | AsyncStorageImpl& operator = (const AsyncStorageImpl&) = delete; |
| 48 | |
| 49 | AsyncStorageImpl(AsyncStorageImpl&&) = delete; |
| 50 | |
| 51 | AsyncStorageImpl& operator = (AsyncStorageImpl&&) = delete; |
| 52 | |
| 53 | AsyncStorageImpl(std::shared_ptr<Engine> engine, |
| 54 | const boost::optional<PublisherId>& pId, |
| 55 | std::shared_ptr<Logger> logger); |
| 56 | |
| 57 | // Meant for UT |
| 58 | AsyncStorageImpl(std::shared_ptr<Engine> engine, |
| 59 | const boost::optional<PublisherId>& pId, |
| 60 | std::shared_ptr<DatabaseConfiguration> databaseConfiguration, |
| 61 | std::shared_ptr<NamespaceConfigurations> namespaceConfigurations, |
Rolf Badorek | 8324d02 | 2019-09-17 16:47:20 +0300 | [diff] [blame] | 62 | std::shared_ptr<Logger> logger, |
| 63 | const AsyncDatabaseDiscoveryCreator& asyncDatabaseDiscoveryCreator); |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 64 | |
| 65 | int fd() const override; |
| 66 | |
| 67 | void handleEvents() override; |
| 68 | |
| 69 | void waitReadyAsync(const Namespace& ns, const ReadyAck& readyAck) override; |
| 70 | |
| 71 | void setAsync(const Namespace& ns, const DataMap& dataMap, const ModifyAck& modifyAck) override; |
| 72 | |
| 73 | void setIfAsync(const Namespace& ns, const Key& key, const Data& oldData, const Data& newData, const ModifyIfAck& modifyIfAck) override; |
| 74 | |
| 75 | void setIfNotExistsAsync(const Namespace& ns, const Key& key, const Data& data, const ModifyIfAck& modifyIfAck) override; |
| 76 | |
| 77 | void getAsync(const Namespace& ns, const Keys& keys, const GetAck& getAck) override; |
| 78 | |
| 79 | void removeAsync(const Namespace& ns, const Keys& keys, const ModifyAck& modifyAck) override; |
| 80 | |
| 81 | void removeIfAsync(const Namespace& ns, const Key& key, const Data& data, const ModifyIfAck& modifyIfAck) override; |
| 82 | |
| 83 | void findKeysAsync(const Namespace& ns, const std::string& keyPrefix, const FindKeysAck& findKeysAck) override; |
| 84 | |
| 85 | void removeAllAsync(const Namespace& ns, const ModifyAck& modifyAck) override; |
| 86 | |
| 87 | //public for UT |
| 88 | AsyncStorage& getOperationHandler(const std::string& ns); |
| 89 | private: |
| 90 | std::shared_ptr<Engine> engine; |
| 91 | std::shared_ptr<DatabaseConfiguration> databaseConfiguration; |
| 92 | std::shared_ptr<NamespaceConfigurations> namespaceConfigurations; |
| 93 | const boost::optional<PublisherId> publisherId; |
| 94 | std::shared_ptr<Logger> logger; |
Rolf Badorek | 8324d02 | 2019-09-17 16:47:20 +0300 | [diff] [blame] | 95 | AsyncDatabaseDiscoveryCreator asyncDatabaseDiscoveryCreator; |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 96 | |
| 97 | AsyncStorage& getRedisHandler(); |
| 98 | AsyncStorage& getDummyHandler(); |
| 99 | }; |
| 100 | } |
| 101 | |
| 102 | #endif |