broadcasting to modules
This commit is contained in:
1 parent
83176ba878
commit
9226796463
20 files changed
+188
-121
No files matched your search
@@ -111,7 +111,7 @@ func (c *commonConfig) CompileConfigs(req domain.CompileConfigsRequest) domain.C
|
||||
func (c *commonConfig) GetLinks(req domain.ConfigIdRequest) domain.CommonConfigLinks {
|
||||
var result domain.CommonConfigLinks
|
||||
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
|
||||
result = service.CommonConfigService.GetCommonConfigLinks(req.Id, state)
|
||||
result = service.CommonConfig.GetCommonConfigLinks(req.Id, state)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
+14
-3
@@ -8,11 +8,16 @@ import (
|
||||
"isp-config-service/service"
|
||||
"isp-config-service/store"
|
||||
"isp-config-service/store/state"
|
||||
"time"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultEventLifetime = 5 * time.Second
|
||||
)
|
||||
|
||||
var Module *module
|
||||
|
||||
type module struct {
|
||||
@@ -30,7 +35,7 @@ type module struct {
|
||||
func (c *module) GetModulesAggregatedInfo() ([]domain.ModuleInfo, error) {
|
||||
var response []domain.ModuleInfo
|
||||
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
|
||||
response = service.ModuleRegistryService.GetAggregatedModuleInfo(state)
|
||||
response = service.ModuleRegistry.GetAggregatedModuleInfo(state)
|
||||
})
|
||||
return response, nil
|
||||
}
|
||||
@@ -89,8 +94,14 @@ func (c *module) GetModuleByName(req domain.GetByModuleNameRequest) (*entity.Mod
|
||||
// @Success 200 "OK"
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /module/broadcast_event [POST]
|
||||
func (c *module) BroadcastEvent(req cluster.BroadcastEvent) error {
|
||||
command := cluster.PrepareBroadcastEventCommand(req)
|
||||
func (c *module) BroadcastEvent(req domain.BroadcastEventRequest) error {
|
||||
cmd := cluster.BroadcastEvent{
|
||||
Event: req.Event,
|
||||
ModuleNames: req.ModuleNames,
|
||||
Payload: req.Payload,
|
||||
PerformUntil: time.Now().UTC().Add(defaultEventLifetime),
|
||||
}
|
||||
command := cluster.PrepareBroadcastEventCommand(cmd)
|
||||
err := PerformSyncApply(command, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user