ClickHouse/src/Storages/RabbitMQ/RabbitMQHandler.h

39 lines
843 B
C++
Raw Normal View History

#pragma once
2020-06-02 13:15:53 +00:00
#include <thread>
#include <memory>
2020-06-02 13:15:53 +00:00
#include <mutex>
#include <amqpcpp.h>
#include <amqpcpp/libevent.h>
#include <amqpcpp/linux_tcp.h>
#include <common/types.h>
#include <amqpcpp/libuv.h>
namespace DB
{
class RabbitMQHandler : public AMQP::LibUvHandler
{
public:
RabbitMQHandler(uv_loop_t * evbase_, Poco::Logger * log_);
void onError(AMQP::TcpConnection * connection, const char * message) override;
2020-06-09 21:52:06 +00:00
void startConsumerLoop(std::atomic<bool> & loop_started);
2020-06-07 11:14:05 +00:00
void startProducerLoop();
void stopWithTimeout();
void stop();
2020-06-11 20:05:35 +00:00
std::atomic<bool> & checkStopIsScheduled() { return stop_scheduled; };
private:
uv_loop_t * loop;
Poco::Logger * log;
2020-06-07 11:14:05 +00:00
timeval tv;
2020-06-11 20:05:35 +00:00
std::atomic<bool> stop_scheduled = false;
2020-06-25 10:25:22 +00:00
std::mutex mutex_before_event_loop;
2020-06-11 20:05:35 +00:00
std::mutex mutex_before_loop_stop;
};
}