Your Name 2 лет назад
Родитель
Сommit
27dcdd970e

+ 45 - 0
framework/core/include/PluginSubscriber.hpp

@@ -0,0 +1,45 @@
+#ifndef __PLUGINSUBSCRIBER_HPP_
+#define __PLUGINSUBSCRIBER_HPP_
+
+#include <iostream>
+#include "PuginFactory.hpp"
+
+namespace gsd
+{
+    /**
+     * @brief PluginSubscriber
+     * 
+     */    
+    template <typename T>
+    class PluginSubscriber{
+        struct Register
+        {
+            // Register
+            Register(){
+                char *Name = nullptr;
+                Name = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, nullptr);
+                std::string pluginName;
+                if(Name != nullptr){
+                    pluginName = Name;
+                    free(Name);
+                }
+                PuginFactory::getPtr()->Regist(pluginName, getObjectPtr);
+            }
+        };
+        
+        /**
+         * @description: 
+         * @return {*}
+         */             
+        static std::shared_ptr<T> getObjectPtr(){
+            return T::getPtr();
+        }
+    private:
+        Register register_;
+    };
+} // namespace gsd
+
+
+
+
+#endif

+ 65 - 0
framework/core/include/PuginFactory.hpp

@@ -0,0 +1,65 @@
+#ifndef __PUGINFACTORY_HPP_
+#define __PUGINFACTORY_HPP_
+
+#include <iostream>
+#include "Util/logger.h"
+#include <unordered_map>
+#include <map>
+#include "UtilBase.hpp"
+#include <vector>
+
+using namespace toolkit;
+using namespace std;
+
+namespace gsd
+{
+    class PuginFactory
+    {
+    private:
+        PuginFactory(){}
+    public:
+        using Ptr = std::shared_ptr<PuginFactory>;
+
+        /**
+         * @description: getPtr
+         * @return {*}
+         */        
+        static std::shared_ptr<PuginFactory> getPtr(){
+            static std::shared_ptr<PuginFactory> PuginFactory_ = nullptr;
+            if(PuginFactory_ == nullptr) PuginFactory_ = std::shared_ptr<PuginFactory>(new PuginFactory);
+            return PuginFactory_;
+        }
+
+        /**
+         * @description: 
+         * @return {*}
+         */        
+        bool Regist(const std::string& Type, std::function<std::shared_ptr<gsd::PluginBase>()> pFunc){
+            InfoL << Type << endl;
+            if(pFunc == nullptr) return false;
+            bool ret = _map.insert(std::make_pair(Type, pFunc)).second;
+            return true;
+        }
+
+        /**
+         * @description: getMap
+         * @return {*}
+         */        
+        unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> getMap(){
+            return _map;
+        }
+        
+        /**
+         * @description: ~PuginFactory
+         * @return {*}
+         */        
+        ~PuginFactory(){
+        }
+
+    protected:  
+        unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> _map;
+    };
+} // namespace gsd
+
+
+#endif

+ 13 - 7
framework/core/include/UtilBase.hpp

@@ -5,7 +5,8 @@
 #include <ctime>
 #include <memory>
 #include <vector>
-
+#include <typeinfo>
+#include <cxxabi.h>
 #include "SendDevice.h"
 #include "NonCopyAble.hpp"
 #include "httplib.h"
@@ -243,8 +244,6 @@ namespace gsd{
         void setPort(int _port){
             this->port = _port;
         }
-
-
     };
 
     /**
@@ -252,7 +251,7 @@ namespace gsd{
      * 
      */    
     class ModuleBase: private NonCopyAble
-    {
+    {   
     public:
         ModuleBase(){}
         ~ModuleBase(){}
@@ -268,6 +267,7 @@ namespace gsd{
          * @return {*}
          */        
         virtual void Destroy() = 0;
+
     };
     
     /**
@@ -276,8 +276,9 @@ namespace gsd{
      */    
     class PluginBase: private ModuleBase
     {
-    private:
-        /* data */
+    protected:
+        bool PluginAlive = false;
+
     public:
         PluginBase(){}
         ~PluginBase(){}
@@ -293,8 +294,13 @@ namespace gsd{
          * @return {*}
          */        
         virtual bool Alive() = 0;
-    };
 
+        /**
+         * @description: Rest
+         * @return {*}
+         */        
+        virtual bool RestPlugin() = 0;
+    };
 };
 
 #endif // _UTILLBASE_HPP_

BIN
lib/libgsd_core.so


BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 6 - 0
modules/CMakeLists.txt

@@ -22,6 +22,7 @@ option(build_Monitor "build module Monitor" ON)
 option(build_TCPClient "build module TCPClient" ON)
 option(build_config "build module config" ON)
 option(build_HttpServer "build module HttpServer" ON)
+option(build_Audit "build module Audit" ON)
 option(build_kafka           "build module kafka" ON)
 
 # ---[ 3rdparty
@@ -73,6 +74,11 @@ if(build_HttpServer)
   include_directories(${PROJECT_SOURCE_DIR}/modules/HttpServer/src)
   install(DIRECTORY HttpServer/include/ DESTINATION include)
 endif()
+if(build_Audit)
+  list(APPEND module_list Audit)
+  include_directories(${PROJECT_SOURCE_DIR}/modules/Audit/src)
+  install(DIRECTORY Audit/include/ DESTINATION include)
+endif()
 
 
 # ---[ kafka

+ 0 - 1
modules/HttpServer/include/HttpServer.hpp

@@ -17,7 +17,6 @@ namespace gsd{
     {
     private:
         HttpServer(): ModuleBase(){
-            InfoL;
         }
     public:
         using Ptr = std::shared_ptr<HttpServer>;

+ 2 - 2
modules/Monitor/include/Monitor.hpp

@@ -3,6 +3,7 @@
 #include <iostream>
 #include "UtilBase.hpp"
 #include "Util/logger.h"
+#include "Network/TcpClient.h"
 #include "kafka_comsumer.h"
 #include "requests.hpp"
 #include "InfineFilter.hpp"
@@ -16,7 +17,6 @@ namespace gsd
     {
     private:
         Monitor(std::string broker, std::string topic, std::string group): ModuleBase(){
-            InfoL;
             this->brokers = broker;
             this->topic_str = topic;
             this->group_id = group;
@@ -50,7 +50,7 @@ namespace gsd
          * @param {*}
          * @return {*}
          */    
-        bool ConsumeData(std::shared_ptr<CNStreamInferData>& cnstreamInferData);
+        std::pair<bool, std::string> ConsumeData(std::shared_ptr<CNStreamInferData>& cnstreamInferData);
 
     protected:
         std::shared_ptr<kafka_consumer_client> m_KafkaConsumer = nullptr; 

+ 2 - 0
modules/Monitor/include/kafka_comsumer.h

@@ -37,6 +37,8 @@ private:
     RdKafka::Topic    *topic_          = nullptr;
     int64_t           offset_          = RdKafka::Topic::OFFSET_BEGINNING;
     int32_t           partition_       = 0;
+
+    bool alive = true;
 };
 
 

+ 11 - 5
modules/Monitor/src/Monitor.cpp

@@ -31,11 +31,16 @@ namespace gsd
      * @param {Ptr&} result
      * @return {*}
      */    
-    bool Monitor::ConsumeData(std::shared_ptr<CNStreamInferData>& cnstreamInferData){
+    std::pair<bool, std::string> Monitor::ConsumeData(std::shared_ptr<CNStreamInferData>& cnstreamInferData){
+        std::pair<bool, std::string> result = std::make_pair<bool, std::string>(false, "");
         std::string json = "";
         // 消费数据
         this->m_KafkaConsumer->ConsumeData(json, 5000);
-        if(json == "") return false;
+        if(json == "") return result;
+        if(json == "ERR__TIMED_OUT"){
+            result.second = json;
+            return result;
+        }
         cnstreamInferData->Objects.clear();
         if(cnstreamInferData->jsonToObject(json)){
             InfineFilter::Ptr infineFilter = InfineFilter::getPtr();
@@ -47,12 +52,13 @@ namespace gsd
             infineFilter->setTimeOut(m_config->TimeOut);
             if(infineFilter != nullptr) {
                 if(infineFilter->judgementResult(cnstreamInferData) != 0){
-                    return false;
+                    return result;
                 }
             }
-            return true;
+            result.first = true;
+            return result;
         }
-        return false;
+        return result;
     }
 
     /**

+ 6 - 2
modules/Monitor/src/kafka_comsumer.cpp

@@ -92,7 +92,7 @@ bool kafka_consumer_client::initClient(){
     if (resp != RdKafka::ERR_NO_ERROR){
         ErrorL << "failed to start consumer : " << RdKafka::err2str(resp).c_str() << endl;
     }
- 
+
     return true;
 }
  
@@ -100,6 +100,7 @@ void kafka_consumer_client::consumer(RdKafka::Message *message, void *opt){
     
     switch(message->err()){
         case RdKafka::ERR__TIMED_OUT:
+            this->alive = false;
             break;
         case RdKafka::ERR_NO_ERROR:
             printf("%.*s\n", static_cast<int>(message->len()),
@@ -119,7 +120,6 @@ void kafka_consumer_client::consumer(RdKafka::Message *message, void *opt){
             run_ = false;
             break;
     }
-    
 }
  
 bool kafka_consumer_client::consume(int timeout_ms){
@@ -152,6 +152,10 @@ void kafka_consumer_client::ConsumeData(std::string& data, int timeout_ms){
     msg = kafka_consumer_->consume(topic_, partition_, timeout_ms);
     switch(msg->err()){
         case RdKafka::ERR__TIMED_OUT:
+            alive = false;
+            delete msg;
+            data = "ERR__TIMED_OUT";
+            return;
             break;
         case RdKafka::ERR_NO_ERROR:
             if(static_cast<int>(msg->len()) > 0) data = static_cast<const char *>(msg->payload());

+ 3 - 3
modules/config/include/config.hpp

@@ -4,7 +4,7 @@
  * @Autor: lishengyin
  * @Date: 2022-03-07 11:52:08
  * @LastEditors: lishengyin
- * @LastEditTime: 2022-09-19 14:15:20
+ * @LastEditTime: 2022-09-29 15:47:50
  */
 #ifndef __CONFIG_H_
 #define __CONFIG_H_
@@ -22,9 +22,9 @@ using namespace std;
 using namespace toolkit;
 using namespace inifile;
 
-#define GSD_MAJOR_VERSION 1
+#define GSD_MAJOR_VERSION 2
 #define GSD_MINOR_VERSION 0
-#define GSD_PATCH_VERSION 6
+#define GSD_PATCH_VERSION 0
 
 class config
 {

+ 91 - 0
plugins/AuditPlugin/include/AuditPlugin.hpp

@@ -0,0 +1,91 @@
+#ifndef __AUDITPLUGIN_HPP_
+#define __AUDITPLUGIN_HPP_
+
+#include <iostream>
+#include "UtilBase.hpp"
+#include "Network/Socket.h"
+#include <mutex>
+#include <condition_variable>
+#include <future>
+#include "Util/logger.h"
+#include "Poller/Timer.h"
+#include <vector>
+#include "PluginSubscriber.hpp"
+#include "PuginFactory.hpp"
+
+using namespace std;
+using namespace toolkit;
+
+namespace gsd
+{
+    class AuditPlugin: public PluginSubscriber<AuditPlugin>, public PluginBase
+    {
+    private:
+        AuditPlugin(): PluginBase(){
+        }
+
+    public:
+        using Ptr = std::shared_ptr<AuditPlugin>;
+
+        /**
+         * @description: 获取Ptr
+         * @return {*}
+         */        
+        static std::shared_ptr<AuditPlugin> getPtr();
+
+        /**
+         * @description: Init
+         * @return {*}
+         */        
+        virtual bool Init();
+
+        /**
+         * @description: StartTask
+         * @return {*}
+         */        
+        virtual bool StartTask();
+
+        /**
+         * @description: Alive
+         * @return {*}
+         */        
+        virtual bool Alive();
+
+        /**
+         * @description: 释放资源
+         * @return {*}
+         */        
+        virtual void Destroy();
+
+        /**
+         * @description: RestPlugin
+         * @return {*}
+         */        
+        virtual bool RestPlugin(){
+            return true;
+        }
+
+        /**
+         * @description: PluginTaskCheck
+         * @return {*}
+         */        
+        virtual bool PluginTaskCheck();
+
+        /**
+         * @description: ~AuditPlugin
+         * @return {*}
+         */        
+        ~AuditPlugin(){
+            InfoL;
+            this->Destroy();
+        }
+
+    private:
+        Timer::Ptr timer = nullptr;
+        unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> map_;
+        std::shared_ptr<ThreadPool> pool = nullptr;
+    };
+} // namespace gsd
+
+
+#endif

+ 70 - 0
plugins/AuditPlugin/src/AuditPlugin.cpp

@@ -0,0 +1,70 @@
+#include "AuditPlugin.hpp"
+
+namespace gsd
+{
+    /**
+     * @description: CreateNew
+     * @return {*}
+     */    
+    std::shared_ptr<AuditPlugin> AuditPlugin::getPtr(){
+        static std::shared_ptr<AuditPlugin> m_AuditPlugin = nullptr;
+        if(m_AuditPlugin == nullptr) m_AuditPlugin = std::shared_ptr<AuditPlugin>(new AuditPlugin);
+        return m_AuditPlugin;
+    }
+
+    /**
+     * @description: 初始化
+     * @return {*}
+     */    
+    bool AuditPlugin::Init(){
+        if(this->pool == nullptr) this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
+        return true;
+    }
+
+    /**
+     * @description: 启动任务
+     * @return {*}
+     */    
+    bool AuditPlugin::StartTask(){
+        if(this->timer == nullptr) this->timer = std::make_shared<toolkit::Timer>(60.0f, [&](){
+            this->PluginTaskCheck();
+            return true;
+        }, nullptr);
+        return true;
+    }
+
+    /**
+     * @description: Destroy
+     * @return {*}
+     */    
+    void AuditPlugin::Destroy(){
+        
+    }
+
+    /**
+     * @description: Alive
+     * @return {*}
+     */        
+    bool AuditPlugin::Alive(){
+        return true;
+    }
+    
+    /**
+     * @description: PluginTaskCheck
+     * @return {*}
+     */    
+    bool AuditPlugin::PluginTaskCheck(){
+        this->map_ =  PuginFactory::getPtr()->getMap();
+        for(auto iter = this->map_.begin(); iter != this->map_.end(); iter++){
+            if(!iter->second()->Alive()) {
+                if(this->pool == nullptr) continue;
+                auto pluginPtr = iter->second();
+                this->pool->async([pluginPtr](){
+                    pluginPtr->RestPlugin();
+                });
+                this->pool->start();
+            }
+        }
+        return true;
+    }  
+} // namespace gsd

+ 7 - 2
plugins/CMakeLists.txt

@@ -19,7 +19,7 @@ option(build_ExpelPlugin "build module ExpelPlugin" ON)
 option(build_HttpPlugin "build module HttpPlugin" ON)
 option(build_MonitorPlugin "build module MonitorPlugin" ON)
 option(build_TcpPlugin "build module TcpPlugin" ON)
-
+option(build_AuditPlugin "build module AuditPlugin" ON)
 
 
 # ---[ 3rdparty
@@ -38,7 +38,7 @@ include_directories(${GSD_ROOT_DIR}/modules/Monitor/include)
 include_directories(${GSD_ROOT_DIR}/modules/TCPClient/include)
 include_directories(${GSD_ROOT_DIR}/modules/HttpServer/include)
 include_directories(${GSD_ROOT_DIR}/modules/config/include)
-
+include_directories(${GSD_ROOT_DIR}/modules/Audit/include)
 
 set(module_list "")
 set(srcs "")
@@ -63,6 +63,11 @@ if(build_TcpPlugin)
   include_directories(${PROJECT_SOURCE_DIR}/modules/TcpPlugin/src)
   install(DIRECTORY TcpPlugin/include/ DESTINATION include)
 endif()
+if(build_AuditPlugin)
+  list(APPEND module_list AuditPlugin)
+  include_directories(${PROJECT_SOURCE_DIR}/modules/AuditPlugin/src)
+  install(DIRECTORY AuditPlugin/include/ DESTINATION include)
+endif()
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 

+ 11 - 3
plugins/ExpelPlugin/include/ExpelPlugin.hpp

@@ -11,17 +11,17 @@
 #include "requests.hpp"
 #include "Expel.hpp"
 #include "InfineFilter.hpp"
+#include "PluginSubscriber.hpp"
 
 using namespace std;
 using namespace toolkit;
 
 namespace gsd
 {
-    class ExpelPlugin: public enable_shared_from_this<ExpelPlugin>, public PluginBase
+    class ExpelPlugin: public PluginSubscriber<ExpelPlugin>, public PluginBase
     {
     private:
         ExpelPlugin(): PluginBase(){
-            InfoL;
         }
 
     public:
@@ -95,7 +95,15 @@ namespace gsd
             InfoL;
             this->Destroy();
         }
-    
+
+        /**
+         * @description: RestPlugin
+         * @return {*}
+         */        
+        virtual bool RestPlugin(){
+            return true;
+        }
+        
     protected:  
         Socket::Ptr sockerUdp = nullptr;
         mutex m_mutex;

+ 0 - 4
plugins/ExpelPlugin/src/ExpelPlugin.cpp

@@ -22,7 +22,6 @@ namespace gsd
         // if(this->timer0 == nullptr) this->timer0 = std::make_shared<Timer>(10.0f, [&](){
         //     return true;
         // }, nullptr);
-
         return true;
     }   
     
@@ -31,7 +30,6 @@ namespace gsd
      * @return {*}
      */    
     bool ExpelPlugin::Alive(){
-
         return true;
     }
 
@@ -40,7 +38,6 @@ namespace gsd
      * @return {*}
      */    
     void ExpelPlugin::Destroy(){
-        
     }
 
     /**
@@ -53,7 +50,6 @@ namespace gsd
             ErrorL << "Sockerudp cannot be created" << endl;
             return false;
         }
-
         this->sockerUdp->bindUdpSock(7777);
         // 数据接收
         this->sockerUdp->setOnRead([&](const Buffer::Ptr &buf, struct sockaddr *addr , int){

+ 10 - 7
plugins/HttpPlugin/include/HttpPlugin.hpp

@@ -10,18 +10,17 @@
 #include "requests.hpp"
 #include "ExpelDevice.h"
 #include "InfineFilter.hpp"
-
+#include "PluginSubscriber.hpp"
 
 using namespace std;
 using namespace toolkit;
 
 namespace gsd
 {
-    class HttpPlugin: public enable_shared_from_this<HttpPlugin>, public PluginBase
+    class HttpPlugin: public PluginSubscriber<HttpPlugin>, public PluginBase
     {
     private:
         HttpPlugin(){
-            InfoL;
         }
 
     public:
@@ -62,9 +61,7 @@ namespace gsd
          * @description: Alive
          * @return {*}
          */        
-        bool Alive(){
-            return true;
-        }
+        bool Alive();
 
         /**
          * @description: 纠察器
@@ -73,7 +70,13 @@ namespace gsd
          * @return {*}
          */        
         std::pair<bool, std::string> getCheck(std::string& ImageBase64, std::string& datas);
-        
+
+        /**
+         * @description: RestPlugin
+         * @return {*}
+         */        
+        virtual bool RestPlugin();
+
         ~HttpPlugin(){}
 
     protected:  

+ 19 - 0
plugins/HttpPlugin/src/HttpPlugin.cpp

@@ -171,4 +171,23 @@ namespace gsd
     std::pair<bool, std::string> HttpPlugin::getCheck(std::string& ImageBase64, std::string& datas){
         return this->m_httpClient->getCheck(ImageBase64, datas);
     }
+    
+    /**
+     * @description: alive
+     * @return {*}
+     */    
+    bool HttpPlugin::Alive(){
+        bool result = true;
+        if(this->m_HttpServer == nullptr) result = false;
+        return result;
+    }
+
+    /**
+     * @description: RestPlugin
+     * @return {*}
+     */    
+    bool HttpPlugin::RestPlugin(){
+        return true;
+    }
+
 } // namespace name

+ 10 - 3
plugins/MonitorPlugin/include/MonitorPlugin.hpp

@@ -9,12 +9,13 @@
 #include "TcpPlugin.hpp"
 #include "InfineFilter.hpp"
 #include "HttpPlugin.hpp"
+#include "PluginSubscriber.hpp"
 
 using namespace std;
 
 namespace gsd
 {
-    class MonitorPlugin: public enable_shared_from_this<MonitorPlugin>, public PluginBase 
+    class MonitorPlugin: public PluginSubscriber<MonitorPlugin>, public PluginBase 
     {
     private:
         MonitorPlugin(): PluginBase(){
@@ -25,10 +26,10 @@ namespace gsd
         ~MonitorPlugin(){}
 
         /**
-         * @description: CreateNew
+         * @description: getPtr
          * @return {*}
          */        
-        static std::shared_ptr<MonitorPlugin> CreateNew();
+        static std::shared_ptr<MonitorPlugin> getPtr();
 
         /**
          * @description: 初始化
@@ -74,6 +75,12 @@ namespace gsd
         */
         bool SaveVideoRecord(HistoryVideo& historyVideo);
 
+        /**
+         * @description: RestPlugin
+         * @return {*}
+         */        
+        virtual bool RestPlugin();
+
     private:
         std::shared_ptr<Monitor> monitor = nullptr;
         std::shared_ptr<ThreadPool> pool = nullptr;

+ 20 - 4
plugins/MonitorPlugin/src/MonitorPlugin.cpp

@@ -6,8 +6,10 @@ namespace gsd
      * @description: CreateNew
      * @return {*}
      */    
-    std::shared_ptr<MonitorPlugin> MonitorPlugin::CreateNew(){
-        return std::shared_ptr<MonitorPlugin>(new MonitorPlugin);
+    std::shared_ptr<MonitorPlugin> MonitorPlugin::getPtr(){
+        static std::shared_ptr<MonitorPlugin> plugin_ = nullptr;
+        if(plugin_ == nullptr) plugin_ = std::shared_ptr<MonitorPlugin>(new MonitorPlugin);
+        return plugin_;
     }
 
     /**
@@ -20,7 +22,7 @@ namespace gsd
             ErrorL << "Monitor's init failed" << endl;
             return false;
         }
-        this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
+        if(this->pool == nullptr) this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
         return true;
     }
 
@@ -29,6 +31,7 @@ namespace gsd
      * @return {*}
      */    
     bool MonitorPlugin::StartTask(){
+        if(this->pool == nullptr) return false;
         this->pool->async([&](){
             while(!this->stop_){
                 this->MonitorProThrd();
@@ -113,7 +116,11 @@ namespace gsd
      */
     bool MonitorPlugin::ConsumeData(FrameInferData::Ptr& result){
         std::shared_ptr<CNStreamInferData> cnstreamInferData = std::make_shared<CNStreamInferData>();
-        if(monitor->ConsumeData(cnstreamInferData)){
+        auto result_data = monitor->ConsumeData(cnstreamInferData);
+        if(result_data.first == false && result_data.second == "ERR__TIMED_OUT"){
+            this->PluginAlive = false;
+        }
+        if(result_data.first){
             // 纠察器
             if(config::getPtr()->InferChecker){
                 CNStreamInferData data = *cnstreamInferData;
@@ -212,6 +219,15 @@ namespace gsd
      * @return {*}
      */        
     bool MonitorPlugin::Alive(){
+        return this->PluginAlive;
+    }
+    
+    /**
+     * @description: RestPlugin
+     * @return {*}
+     */    
+    bool MonitorPlugin::RestPlugin(){
         return true;
     }
+
 } // namespace gsd

+ 10 - 2
plugins/TcpPlugin/include/TcpPlugin.hpp

@@ -11,17 +11,17 @@
 #include "ExpelDevice.h"
 #include "ExpelPlugin.hpp"
 #include "uuid.hpp"
+#include "PluginSubscriber.hpp"
 
 using namespace std;
 using namespace utility;
 
 namespace gsd
 {
-    class TcpPlugin: public enable_shared_from_this<TcpPlugin>, public PluginBase 
+    class TcpPlugin: public PluginSubscriber<TcpPlugin>, public PluginBase 
     {
     private:
         TcpPlugin(): PluginBase(){
-
         }
     public:
         using Ptr = std::shared_ptr<TcpPlugin>;
@@ -99,6 +99,14 @@ namespace gsd
          */    
         void sendRequest(std::string RequestId,std::string CommandEnum, std::string& data,function<void(int, std::string)> t);
 
+        /**
+         * @description: RestPlugin
+         * @return {*}
+         */        
+        virtual bool RestPlugin(){
+            return true;
+        }
+
     private:
     
         // TCP对象

+ 1 - 0
source/CMakeLists.txt

@@ -55,6 +55,7 @@ include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
+include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
 
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)

+ 3 - 0
source/UserApp/include/UserApp.hpp

@@ -11,6 +11,7 @@
 #include "TcpPlugin.hpp"
 #include "ExpelPlugin.hpp"
 #include "MonitorPlugin.hpp"
+#include "AuditPlugin.hpp"
 
 using namespace std;
 using namespace toolkit;
@@ -70,6 +71,8 @@ namespace gsd
         TcpPlugin::Ptr m_TcpPlugin = nullptr;
         ExpelPlugin::Ptr m_ExpelPlugin = nullptr;
         MonitorPlugin::Ptr m_MonitorPlugin = nullptr;
+        AuditPlugin::Ptr m_AuditPlugin = nullptr;
+        
         Timer::Ptr timer0 = nullptr;
     };
 } // namespace gsd

+ 14 - 1
source/UserApp/src/UserApp.cpp

@@ -60,12 +60,19 @@ namespace gsd
         }
 
         // MonitorPlugin
-        if(this->m_MonitorPlugin == nullptr) m_MonitorPlugin = MonitorPlugin::CreateNew();
+        if(this->m_MonitorPlugin == nullptr) m_MonitorPlugin = MonitorPlugin::getPtr();
         if(!this->m_MonitorPlugin->Init()){
             ErrorL << "MonitorPlugin init failed" << endl;
             return false;
         }
 
+        // AuditPlugin
+        if(this->m_AuditPlugin == nullptr) m_AuditPlugin = AuditPlugin::getPtr();
+        if(!this->m_AuditPlugin->Init()){
+            ErrorL << "AuditPlugin init failed" << endl;
+            return false;
+        }
+
         // 释放资源
         NoticeCenter::Instance().addListener(0, NOTICE_DESTROY,
             [&](){
@@ -92,10 +99,16 @@ namespace gsd
 
         // TCP启动任务
         if(this->m_TcpPlugin != nullptr) this->m_TcpPlugin->StartTask();
+
         // Expel启动任务
         if(this->m_ExpelPlugin != nullptr) this->m_ExpelPlugin->StartTask();
+
         // Monitor启动任务
         if(this->m_MonitorPlugin != nullptr) this->m_MonitorPlugin->StartTask();
+
+        // auditPlugin
+        if(this->m_AuditPlugin != nullptr) this->m_AuditPlugin->StartTask();
+
         // HTTP启动任务
         if(this->m_HttpPlugin != nullptr) this->m_HttpPlugin->StartTask();