mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
|
#pragma once
|
||
|
|
||
|
#include <Storages/RabbitMQ/UVLoop.h>
|
||
|
#include <Storages/RabbitMQ/RabbitMQHandler.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
struct RabbitMQConfiguration
|
||
|
{
|
||
|
String host;
|
||
|
UInt16 port;
|
||
|
String username;
|
||
|
String password;
|
||
|
String vhost;
|
||
|
|
||
|
bool secure;
|
||
|
String connection_string;
|
||
|
};
|
||
|
|
||
|
class RabbitMQConnection
|
||
|
{
|
||
|
public:
|
||
|
RabbitMQConnection(const RabbitMQConfiguration & configuration_, Poco::Logger * log_);
|
||
|
|
||
|
bool isConnected();
|
||
|
|
||
|
bool connect();
|
||
|
|
||
|
bool reconnect();
|
||
|
|
||
|
void disconnect(bool immediately = false);
|
||
|
|
||
|
void heartbeat() { connection->heartbeat(); }
|
||
|
|
||
|
bool closed() { return connection->closed(); }
|
||
|
|
||
|
ChannelPtr createChannel();
|
||
|
|
||
|
/// RabbitMQHandler is thread safe. Any public methods can be called concurrently.
|
||
|
RabbitMQHandler & getHandler() { return event_handler; }
|
||
|
|
||
|
String connectionInfoForLog() const;
|
||
|
|
||
|
private:
|
||
|
RabbitMQConfiguration configuration;
|
||
|
Poco::Logger * log;
|
||
|
|
||
|
UVLoop loop;
|
||
|
RabbitMQHandler event_handler;
|
||
|
|
||
|
std::unique_ptr<AMQP::TcpConnection> connection;
|
||
|
std::mutex mutex;
|
||
|
};
|
||
|
|
||
|
using RabbitMQConnectionPtr = std::unique_ptr<RabbitMQConnection>;
|
||
|
|
||
|
}
|