7 #include <QVariantList> 8 #include <QSharedPointer> 12 #include "connectionconfig.h" 13 #include "exception.h" 16 #include "scancommand.h" 20 class AbstractTransporter;
21 class CommandExecutor;
23 typedef QMap<int, int> DatabaseList;
36 DatabaseList databases;
41 QVariantMap toVariantMap();
46 static ServerInfo fromString(
const QString& info);
58 friend class AbstractTransporter;
61 enum class Mode { Normal, PubSub, Cluster, Sentinel };
83 virtual bool connect(
bool wait=
true);
89 virtual bool isConnected();
94 virtual void disconnect();
117 virtual double getServerVersion();
123 virtual DatabaseList getKeyspaceInfo();
132 typedef std::function<void(const RawKeysList&, const QString&)> RawKeysListCallback;
140 virtual void getDatabaseKeys(RawKeysListCallback callback,
141 const QString& pattern=QString(
"*"),
149 virtual void getClusterKeys(RawKeysListCallback callback,
150 const QString &pattern);
153 typedef QPair<QString, int> Host;
154 typedef QList<Host> HostList;
160 HostList getMasterNodes();
169 void command(
const Command& cmd);
176 void command(QList<QByteArray> rawCmd,
int db = -1);
185 void command(QList<QByteArray> rawCmd, QObject *owner,
186 RedisClient::Command::Callback callback,
int db = -1);
201 Response commandSync(QList<QByteArray> rawCmd,
int db = -1);
206 Response commandSync(QString cmd,
int db = -1);
207 Response commandSync(QString cmd, QString arg1,
int db = -1);
208 Response commandSync(QString cmd, QString arg1, QString arg2,
int db = -1);
209 Response commandSync(QString cmd, QString arg1, QString arg2, QString arg3,
int db = -1);
226 virtual void retrieveCollection(QSharedPointer<ScanCommand> cmd,
227 CollectionCallback callback);
234 virtual void retrieveCollectionIncrementally(QSharedPointer<ScanCommand> cmd,
235 IncrementalCollectionCallback callback);
241 virtual void runCommand(
const Command &cmd);
248 bool waitForIdle(uint timeout);
254 void setTransporter(QSharedPointer<AbstractTransporter>);
255 QSharedPointer<AbstractTransporter> getTransporter()
const;
258 void addCommandToWorker(
const Command&);
259 void error(
const QString&);
260 void log(
const QString&);
264 void authError(
const QString&);
267 void reconnectTo(
const QString& host,
int port);
270 void createTransporter();
271 bool isTransporterRunning();
273 Response internalCommandSync(QList<QByteArray> rawCmd);
275 void processScanCommand(QSharedPointer<ScanCommand> cmd,
276 CollectionCallback callback,
277 QSharedPointer<QVariantList> result=QSharedPointer<QVariantList>(),
278 bool incrementalProcessing=
false);
280 void changeCurrentDbNumber(
int db);
287 QSharedPointer<QThread> m_transporterThread;
288 QSharedPointer<AbstractTransporter> m_transporter;
293 QMutex m_dbNumberMutex;
295 bool m_stoppingTransporter;
296 RawKeysListCallback m_wrapper;
The Command class.
Definition: command.h:18
The Connection class Main client class.
Definition: connection.h:53
std::function< void(QVariant, QString err, bool final)> IncrementalCollectionCallback
IncrementalCollectionCallback.
Definition: connection.h:219
The ServerInfo struct Represents redis-server information parsed from INFO command.
Definition: connection.h:29
Definition: connection.h:62
QList< QByteArray > RawKeysList
RawKeysList.
Definition: connection.h:131
Definition: connection.h:38
The ConnectionConfig class Supports loading settigns from JSON objects.
Definition: connectionconfig.h:16
Definition: response.h:12
std::function< void(QVariant, QString err)> CollectionCallback
CollectionCallback.
Definition: connection.h:214