Monitoring  3.3.4
O2 Monitoring library
Kafka.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef ALICEO2_MONITORING_TRANSPORTS_KAFKA_H
17 #define ALICEO2_MONITORING_TRANSPORTS_KAFKA_H
18 
19 #include "TransportInterface.h"
20 
21 #include <boost/array.hpp>
22 #include <boost/asio.hpp>
23 #include <boost/algorithm/string.hpp>
24 #include <chrono>
25 #include <string>
26 #include <librdkafka/rdkafkacpp.h>
27 
28 namespace o2
29 {
31 namespace monitoring
32 {
34 namespace transports
35 {
36 
38 class Kafka : public TransportInterface
39 {
40  public:
45  Kafka(const std::string& host, unsigned int port, const std::string& topic = "test");
46 
48  ~Kafka();
49 
52  void send(std::string&& message) override;
53 
54  private:
56  RdKafka::Producer* producer;
57 
59  std::string mTopic;
60 };
61 
62 } // namespace transports
63 } // namespace monitoring
64 } // namespace o2
65 
66 #endif // ALICEO2_MONITORING_TRANSPORTS_KAFKA_H
Definition: Backend.h:23
~Kafka()
Deletes producer.
Definition: Kafka.cxx:48
Transport interface for backends.
Definition: TransportInterface.h:31
Kafka(const std::string &host, unsigned int port, const std::string &topic="test")
Definition: Kafka.cxx:29
void send(std::string &&message) override
Definition: Kafka.cxx:53
Transport that sends string formatted metrics via Kafka.
Definition: Kafka.h:38