Commit b9686f4c authored by Lei Li's avatar Lei Li
Browse files

feat: 增加发布消息的处理

parent b2bed5e2
......@@ -12,6 +12,8 @@ const (
ConsumerTopicPluginUpgrade = "plugin-upgrade"
ConsumerTopicStartupPlugin = "startup-plugin"
ConsumerTopicStopPlugin = "stop-plugin"
PublishTopicReportInfo = "report-info"
)
var SubscribePrefixInfo = ""
......
......@@ -4,7 +4,7 @@ go 1.23.2
replace linkfog.com/public => web.lueluesay.top/git/lil/public v0.0.0-20241017054747-f08bac907b6c
replace linkfog.com/pluginx => web.lueluesay.top/git/lil/pluginx v0.0.0-20241017031415-3651ccc20390
replace linkfog.com/pluginx => web.lueluesay.top/git/lil/pluginx v0.0.0-20241017112237-9affa4009a35
require (
github.com/beevik/ntp v1.4.3
......
......@@ -10,6 +10,7 @@ import (
// 插件名
const (
AgentSelfPlugin = "agent"
PushStreamingPlugin = "pushStreaming"
ReportDCSInfoPlugin = "reportDCSInfo"
)
......
......@@ -165,7 +165,7 @@ func (p *Plugin) dealWithSig(msg *global.Message) {
case global.ConsumerTopicPluginUpgrade:
case global.ConsumerTopicStartupPlugin:
go chatWithPlugin(p.grpcClient, ReportDCSInfoPlugin, global.PublishTopicReportInfo)
case global.ConsumerTopicStopPlugin:
}
}
package plugin
import (
"context"
"agent/cmd/agent/global"
"linkfog.com/pluginx/pluginrpc"
"linkfog.com/public/lib/l"
)
func chatWithPlugin(client *pluginrpc.PluginGrpcClient, pluginName string, topicName string) {
req := pluginrpc.NewReq(AgentSelfPlugin, pluginName, "", []byte{})
chatClient, err := client.Chat(context.Background(), req)
if err != nil {
l.Error("ChatClient err:", err)
return
}
for {
res, err := chatClient.Recv()
if err != nil {
l.Error("ChatClient receive err:", err)
return
}
l.Infof("receive message: %v", res)
global.HostInfoTail.MQTTInfo.PublishChan <- &global.Message{
Key: topicName,
Payload: string(res.Data),
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment