This commit is contained in:
DeniskaRediska committed 2019-10-11 18:00:31 +03:00
1 parent f1bce695fb
commit 94397ea4c7
4 files changed
+13 -15

No files matched your search

+4 -4
View File
@@ -14,8 +14,8 @@ type clusterStateService struct{}
func (l clusterStateService) HandleUpdateBackendDeclarationCommand(declaration structure.BackendDeclaration, state state.State) (state.State, error) {
changed := state.UpsertBackend(declaration)
if changed {
DiscoveryService.BroadcastModuleAddresses(declaration.ModuleName, &state)
RoutesService.BroadcastRoutes(&state)
DiscoveryService.BroadcastModuleAddresses(declaration.ModuleName, state)
RoutesService.BroadcastRoutes(state)
}
return state, nil
}
@@ -23,8 +23,8 @@ func (l clusterStateService) HandleUpdateBackendDeclarationCommand(declaration s
func (l clusterStateService) HandleDeleteBackendDeclarationCommand(declaration structure.BackendDeclaration, state state.State) (state.State, error) {
deleted := state.DeleteBackend(declaration)
if deleted {
DiscoveryService.BroadcastModuleAddresses(declaration.ModuleName, &state)
RoutesService.BroadcastRoutes(&state)
DiscoveryService.BroadcastModuleAddresses(declaration.ModuleName, state)
RoutesService.BroadcastRoutes(state)
}
return state, nil
}
+6 -8
View File
@@ -12,18 +12,16 @@ var SchemaService schemaService
type schemaService struct{}
func (schemaService) HandleUpdateConfigSchema(schema entity.ConfigSchema, state state.State) (state.State, error) {
schema = state.UpdateSchema(schema)
//todo add check is leader?
_, err := model.SchemaRep.Upsert(schema)
if err != nil {
return state, err
}
_, ok := state.GetModuleById(schema.ModuleId)
if !ok {
return state, errors.Errorf("module with id %s not found", schema.ModuleId)
}
//todo add check is leader?
schema = state.UpdateSchema(schema)
_, err := model.SchemaRep.Upsert(schema)
if err != nil {
return state, err
}
return state, nil
}
+1 -1
View File
@@ -65,7 +65,7 @@ func (s State) BackendExist(backend structure.BackendDeclaration) (exist bool) {
return s.mesh.BackendExist(backend)
}
func (s *State) GetModuleByName(moduleName string) (entity.Module, bool) {
func (s State) GetModuleByName(moduleName string) (entity.Module, bool) {
return s.modules.GetByName(moduleName)
}
+2 -2
View File
@@ -27,10 +27,10 @@ func (h *socketEventHandler) SubscribeAll() {
OnConnect(h.handleConnect).
OnDisconnect(h.handleDisconnect).
OnError(h.handleError).
OnWithAck(utils.ModuleSendConfigSchema, h.handleConfigSchema).
OnWithAck(cluster.ApplyCommandEvent, h.applyCommandOnLeader).
OnWithAck(utils.ModuleReady, h.handleModuleReady).
OnWithAck(utils.ModuleSendRequirements, h.handleModuleRequirements)
OnWithAck(utils.ModuleSendRequirements, h.handleModuleRequirements).
OnWithAck(utils.ModuleSendConfigSchema, h.handleConfigSchema)
}
func (h *socketEventHandler) handleConnect(conn ws.Conn) {