add(cluster check 'is leader')
This commit is contained in:
1 parent
fec8a759bc
commit
cb8ae318c4
2 files changed
+10
-11
No files matched your search
+7
-5
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/holder"
|
||||
"isp-config-service/model"
|
||||
"isp-config-service/store/state"
|
||||
)
|
||||
@@ -17,11 +18,12 @@ func (schemaService) HandleUpdateConfigSchema(schema entity.ConfigSchema, state
|
||||
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
|
||||
if holder.ClusterClient.IsLeader() {
|
||||
schema = state.UpdateSchema(schema)
|
||||
_, err := model.SchemaRep.Upsert(schema)
|
||||
if err != nil {
|
||||
return state, err
|
||||
}
|
||||
}
|
||||
return state, nil
|
||||
}
|
||||
+3
-6
@@ -84,14 +84,11 @@ func (h *socketEventHandler) handleConfigSchema(conn ws.Conn, data []byte) strin
|
||||
if err := jsoniter.Unmarshal(data, &configSchema); err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
var (
|
||||
module entity.Module
|
||||
ok bool
|
||||
)
|
||||
module := new(entity.Module)
|
||||
h.store.VisitReadState(func(readState state.ReadState) {
|
||||
module, ok = readState.GetModuleByName(moduleName)
|
||||
module = readState.GetModuleByName(moduleName)
|
||||
})
|
||||
if !ok {
|
||||
if module == nil {
|
||||
return fmt.Sprintf("module with name %s not found", moduleName)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user