Monitor.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. using namespace std;
  9. using namespace toolkit;
  10. namespace gsd
  11. {
  12. class Monitor: public enable_shared_from_this<Monitor>, public ModuleBase
  13. {
  14. private:
  15. Monitor(std::string broker, std::string topic, std::string group): ModuleBase(){
  16. InfoL;
  17. this->brokers = broker;
  18. this->topic_str = topic;
  19. this->group_id = group;
  20. }
  21. public:
  22. using Ptr = std::shared_ptr<Monitor>;
  23. ~Monitor(){}
  24. /**
  25. * @description: 初始化
  26. * @return {*}
  27. */
  28. virtual bool Init();
  29. /**
  30. * @description:
  31. * @return {*}
  32. */
  33. virtual void Destroy();
  34. /**
  35. * @description: 创建新的
  36. * @return {*}
  37. */
  38. static std::shared_ptr<Monitor> CreateNew(std::string broker, std::string topic, std::string group);
  39. /**
  40. * @description: 消费数据
  41. * @param {*}
  42. * @return {*}
  43. */
  44. bool ConsumeData(FrameInferData::Ptr& result);
  45. protected:
  46. std::shared_ptr<kafka_consumer_client> m_KafkaConsumer = nullptr;
  47. std::string brokers = "localhost";
  48. std::string topic_str = "CnstreamData_0";
  49. std::string group_id = "cnstream-group";
  50. };
  51. } // namespace gsd
  52. #endif