Add disconnect

This commit is contained in:
Jean Flach 2018-10-17 14:33:57 +02:00 committed by Michael Friedrich
parent d96dcf869e
commit 64515b81e3
2 changed files with 10 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include <hiredis/hiredis.h>
#include <base/logger.hpp>
#include "base/utility.hpp"
#include "redis/rediswriter.hpp"
using namespace icinga;
/*
@ -80,9 +81,14 @@ void RedisConnection::Connect() {
//TODO: Authentication, DB selection, error handling
}
void RedisConnection::Disconnect()
{
redisAsyncDisconnect(m_Context);
}
void RedisConnection::DisconnectCallback(const redisAsyncContext *c, int status) {
if (status == REDIS_OK)
Log(LogCritical, "RedisWriter") << "Redis disconnected by user";
Log(LogInformation, "RedisWriter") << "Redis disconnected by us";
else
Log(LogCritical, "Rediswriter") << "Redis disconnected for reasons";

View File

@ -40,9 +40,10 @@ public:
void Start();
void Connect();
void Disconnect();
void ExecuteQuery(const std::vector<String>& query, redisCallbackFn *fn = nullptr, void *privdata = nullptr);
void ExecuteQueries(const std::vector<std::vector<String> >& queries, redisCallbackFn *fn = nullptr, void *privdata = nullptr);
void ExecuteQuery(const std::vector<String>& query, redisCallbackFn *fn = NULL, void *privdata = NULL);
void ExecuteQueries(const std::vector<std::vector<String> >& queries, redisCallbackFn *fn = NULL, void *privdata = NULL);
private: