Monitor.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __MONITOR_HPP_
  2. #define __MONITOR_HPP_
  3. #include <iostream>
  4. #include "UtilBase.hpp"
  5. #include "Util/logger.h"
  6. #include "Network/TcpClient.h"
  7. #include "kafka_comsumer.h"
  8. #include "requests.hpp"
  9. #include "InfineFilter.hpp"
  10. using namespace std;
  11. using namespace toolkit;
  12. namespace gsd
  13. {
  14. class Monitor: public enable_shared_from_this<Monitor>, public ModuleBase
  15. {
  16. private:
  17. Monitor(std::string broker, std::string topic, std::string group): ModuleBase(){
  18. this->brokers = broker;
  19. this->topic_str = topic;
  20. this->group_id = group;
  21. }
  22. public:
  23. using Ptr = std::shared_ptr<Monitor>;
  24. ~Monitor(){}
  25. /**
  26. * @description: 初始化
  27. * @return {*}
  28. */
  29. virtual bool Init();
  30. /**
  31. * @description:
  32. * @return {*}
  33. */
  34. virtual void Destroy();
  35. /**
  36. * @description: 创建新的
  37. * @return {*}
  38. */
  39. static std::shared_ptr<Monitor> CreateNew(std::string broker, std::string topic, std::string group);
  40. /**
  41. * @description: 消费数据
  42. * @param {*}
  43. * @return {*}
  44. */
  45. std::pair<bool, std::string> ConsumeData(std::shared_ptr<CNStreamInferData>& cnstreamInferData);
  46. protected:
  47. std::shared_ptr<kafka_consumer_client> m_KafkaConsumer = nullptr;
  48. std::string brokers = "localhost";
  49. std::string topic_str = "CnstreamData_0";
  50. std::string group_id = "cnstream-group";
  51. };
  52. } // namespace gsd
  53. #endif