diff --git a/cmd/server/app/network/controller/plugin.go b/cmd/server/app/network/controller/plugin.go index 9de093aaa737345fb4711c8e751537e7aa312289..c27fe54715357a95e44de9195c496590722da5af 100644 --- a/cmd/server/app/network/controller/plugin.go +++ b/cmd/server/app/network/controller/plugin.go @@ -82,8 +82,8 @@ func AddPluginHandler(c *gin.Context) { } msgData := commonSDK.MessageData{ - MsgType: eventSDK.MsgPluginRemove, - MessageType: eventSDK.GetMessageTypeString(eventSDK.MsgPluginRemove), + MsgType: eventSDK.MsgPluginAdd, + MessageType: eventSDK.GetMessageTypeString(eventSDK.MsgPluginAdd), TimeStamp: time.Now(), Data: eventSDK.MDPluginChange{ PluginName: p.Name, @@ -98,7 +98,7 @@ func AddPluginHandler(c *gin.Context) { return } ms := commonSDK.EventMessage{ - MessageType: eventSDK.MsgUserLogin, + MessageType: eventSDK.MsgPluginAdd, MessageData: msgDataString, } plugin.PublishEvent(ms) @@ -193,7 +193,7 @@ func UnloadPluginHandler(c *gin.Context) { return } ms := commonSDK.EventMessage{ - MessageType: eventSDK.MsgUserLogin, + MessageType: eventSDK.MsgPluginRemove, MessageData: msgDataString, } plugin.PublishEvent(ms) diff --git a/cmd/server/app/network/controller/user.go b/cmd/server/app/network/controller/user.go index 0efa42ca1174a976c1ac99d6920a8687660b055b..48c77fdb3a614799adbc258425b7df0668130154 100644 --- a/cmd/server/app/network/controller/user.go +++ b/cmd/server/app/network/controller/user.go @@ -167,7 +167,7 @@ func Logout(c *gin.Context) { return } ms := commonSDK.EventMessage{ - MessageType: eventSDK.MsgUserLogin, + MessageType: eventSDK.MsgUserLogout, MessageData: msgDataString, } plugin.PublishEvent(ms) diff --git a/cmd/server/app/service/plugin/heartbeat.go b/cmd/server/app/service/plugin/heartbeat.go index 6668abeb995d2438fc671bef07d69867c125ed9d..a0bffa7c8cc0ddafd2b26855429944e300820477 100644 --- a/cmd/server/app/service/plugin/heartbeat.go +++ b/cmd/server/app/service/plugin/heartbeat.go @@ -3,9 +3,12 @@ package plugin import ( "time" + eventSDK "gitee.com/openeuler/PilotGo-plugins/event/sdk" "gitee.com/openeuler/PilotGo/pkg/dbmanager/redismanager" "gitee.com/openeuler/PilotGo/sdk/logger" "gitee.com/openeuler/PilotGo/sdk/plugin/client" + + commonSDK "gitee.com/openeuler/PilotGo/sdk/common" "k8s.io/apimachinery/pkg/util/wait" ) @@ -43,6 +46,28 @@ func checkAndRebind() { LastConnect: time.Now(), } redismanager.Set(key, value) + + // + msgData := commonSDK.MessageData{ + MsgType: eventSDK.MsgPluginOnline, + MessageType: eventSDK.GetMessageTypeString(eventSDK.MsgPluginOnline), + TimeStamp: time.Now(), + Data: eventSDK.MDPluginChange{ + PluginName: p.Name, + Version: p.Version, + Url: p.Url, + Description: p.Description, + }, + } + msgDataString, err := msgData.ToMessageDataString() + if err != nil { + logger.Error("event message data marshal failed:%v", err.Error()) + } + ms := commonSDK.EventMessage{ + MessageType: eventSDK.MsgPluginOnline, + MessageData: msgDataString, + } + PublishEvent(ms) } } }