From 1ddbe43618d1c6d8be58edf57a41781b11ac16fb Mon Sep 17 00:00:00 2001 From: Maxim Merzhanov Date: Wed, 4 Sep 2019 18:48:54 +0300 Subject: [PATCH] fix --- subs/client.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/subs/client.go b/subs/client.go index b7aa162..c6baba9 100644 --- a/subs/client.go +++ b/subs/client.go @@ -31,14 +31,17 @@ func (h *socketEventHandler) handleModuleReady(conn ws.Conn, data []byte) string logger.Warnf("SOCKET ROUTES ERROR, handleModuleDeclaration: %s, error validate routes data: %s", conn.Id(), errors) return err.Error() } + var changed bool h.store.VisitReadState(func(state state.ReadState) { - if state.CheckBackendChanged(declaration) { - conn.SetBackendDeclaration(declaration) - command := service.ClusterStateService.PrepareUpdateBackendDeclarationCommand(declaration) - i, err := h.cluster.SyncApply(command) - logger.Debug("cluster.SyncApply:", i, err) - } + changed = state.CheckBackendChanged(declaration) }) + if changed { + conn.SetBackendDeclaration(declaration) + command := service.ClusterStateService.PrepareUpdateBackendDeclarationCommand(declaration) + i, err := h.cluster.SyncApply(command) + logger.Debug("cluster.SyncApply:", i, err) + } + return ok }