/* Copyright (c) 2018-2019 Nokia. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef SHAREDDATALAYER_REDIS_ASYNCCOMMANDDISPATCHER_HPP_ #define SHAREDDATALAYER_REDIS_ASYNCCOMMANDDISPATCHER_HPP_ #include #include #include #include #include #include "private/asyncconnection.hpp" #include "private/logger.hpp" namespace shareddatalayer { class Engine; namespace redis { class ContentsBuilder; class Reply; struct Contents; struct DatabaseInfo; class AsyncCommandDispatcher { public: AsyncCommandDispatcher(const AsyncCommandDispatcher&) = delete; AsyncCommandDispatcher& operator = (const AsyncCommandDispatcher&) = delete; virtual ~AsyncCommandDispatcher() = default; using ConnectAck = std::function; virtual void waitConnectedAsync(const ConnectAck& connectAck) = 0; // NOTE: If there are connections open to several database instances, callback // does not identify that which one was disconnected. using DisconnectCb = std::function; virtual void registerDisconnectCb(const DisconnectCb& disconnectCb) = 0; using CommandCb = std::function; virtual void dispatchAsync(const CommandCb& commandCb, const AsyncConnection::Namespace& ns, const Contents& contents) = 0; virtual void disableCommandCallbacks() = 0; static std::shared_ptr create(Engine& engine, const DatabaseInfo& databaseInfo, std::shared_ptr contentsBuilder, bool usePermanentCommandCallbacks, std::shared_ptr logger, bool usedForSentinel); protected: AsyncCommandDispatcher() = default; }; } } #endif