add module/broadcast_event method

This commit is contained in:
Maxim Merzhanov committed 2020-03-23 16:49:21 +03:00
1 parent 96dee8dee3
commit 28aa3eae33
13 files changed
+105 -11

No files matched your search

+5 -3
View File
@@ -31,9 +31,11 @@ func PerformSyncApply(command []byte, commandName string, responsePtr interface{
}).Warnf(codes2.SyncApplyError, "apply command")
return unknownError()
}
err = json.Unmarshal(applyLogResponse.Result, responsePtr)
if err != nil {
return unknownError()
if responsePtr != nil {
err = json.Unmarshal(applyLogResponse.Result, responsePtr)
if err != nil {
return unknownError()
}
}
return nil
}
+19
View File
@@ -85,6 +85,25 @@ func (c *module) GetModuleByName(req domain.GetByModuleNameRequest) (*entity.Mod
return module, nil
}
// @Summary Метод отправки события всем подключенным модулям
// @Description Модуль
// @Tags Модули
// @Accept json
// @Produce json
// @Param body body cluster.BroadcastEvent true "событие"
// @Success 200 ""
// @Failure 500 {object} structure.GrpcError
// @Router /module/broadcast_event [POST]
func (c *module) BroadcastEvent(req cluster.BroadcastEvent) error {
command := cluster.PrepareBroadcastEventCommand(req)
err := PerformSyncApply(command, "BroadcastEventCommand", nil)
if err != nil {
return err
}
return nil
}
func NewModule(rstore *store.Store) *module {
return &module{
rstore: rstore,