Adds support for clustered websocket messages for products (#21737)

* Adds support for clustered websocket messages for products

* Update app/cluster_handlers.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
Miguel de la Cruz
2022-11-25 18:02:30 +01:00
коммит произвёл GitHub
родитель f390d88d0c
Коммит e031b16b16
2 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@@ -37,6 +37,10 @@ func (s *Server) clusterPluginEventHandler(msg *model.ClusterMessage) {
return
}
pluginID := msg.Props["PluginID"]
// if the plugin key is empty, the message might be coming from a product.
if pluginID == "" {
pluginID = msg.Props["ProductID"]
}
eventID := msg.Props["EventID"]
if pluginID == "" || eventID == "" {
mlog.Warn("Invalid ClusterMessage.Props values for plugin event",

Просмотреть файл

@@ -499,6 +499,12 @@ func (env *Environment) HooksForPlugin(id string) (Hooks, error) {
}
}
if p, ok := env.registeredProducts.Load(id); ok {
rp := p.(*registeredProduct)
return rp.adapter, nil
}
return nil, fmt.Errorf("plugin not found: %v", id)
}