Monitor.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __MONITOR_HPP_
  2. #define __MONITOR_HPP_
  3. #include <iostream>
  4. #include "UtilBase.hpp"
  5. #include "Util/logger.h"
  6. #include "kafka_comsumer.h"
  7. #include "requests.hpp"
  8. #include "InfineFilter.hpp"
  9. using namespace std;
  10. using namespace toolkit;
  11. namespace gsd
  12. {
  13. class Monitor: public enable_shared_from_this<Monitor>, public ModuleBase
  14. {
  15. private:
  16. Monitor(std::string broker, std::string topic, std::string group): ModuleBase(){
  17. InfoL;
  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. bool 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