fix generate version id

This commit is contained in:
DeniskaRediska committed 2020-06-09 13:41:56 +03:00
1 parent 6387947b22
commit 1c66729974
5 files changed
+16 -12

No files matched your search

+4 -3
View File
@@ -28,9 +28,10 @@ type ActivateConfig struct {
}
type UpsertConfig struct {
Config entity.Config
Create bool
Unsafe bool
Config entity.Config
VersionId string
Create bool
Unsafe bool
}
type DeleteConfigs struct {
+3 -2
View File
@@ -64,8 +64,9 @@ func (c *config) CreateUpdateConfig(config domain.CreateUpdateConfigRequest) (*d
config.CreatedAt = now
config.UpdatedAt = now
upsertConfig := cluster.UpsertConfig{
Config: config.Config,
Unsafe: config.Unsafe,
Config: config.Config,
Unsafe: config.Unsafe,
VersionId: state.GenerateId(),
}
if config.Id == "" {
upsertConfig.Config.Id = state.GenerateId()
+1 -1
View File
@@ -147,7 +147,7 @@ func (cs configService) HandleUpsertConfigCommand(upsertConfig cluster.UpsertCon
config.Version = oldCfg.Version + 1
state.WritableConfigs().UpdateById(config)
_ = ConfigHistory.SaveConfigVersion(oldCfg, state)
versionConfig = ConfigHistory.SaveConfigVersion(upsertConfig.VersionId, oldCfg, state)
}
if holder.ClusterClient.IsLeader() {
+4 -3
View File
@@ -42,14 +42,15 @@ func (configHistoryService) HandleGetAllVersionConfigCommand(cfg cluster.Identit
return cluster.NewResponse(resp)
}
func (s configHistoryService) SaveConfigVersion(oldConfig entity.Config, writableState state.WritableState) entity.VersionConfig {
func (s configHistoryService) SaveConfigVersion(id string, oldConfig entity.Config,
state state.WritableState) entity.VersionConfig {
cfg := entity.VersionConfig{
Id: state.GenerateId(), //todo all node generate own id
Id: id,
ConfigVersion: oldConfig.Version,
ConfigId: oldConfig.Id,
Data: oldConfig.Data,
}
removedVersionId := writableState.WriteableVersionConfigStore().Update(cfg)
removedVersionId := state.WriteableVersionConfigStore().Update(cfg)
if holder.ClusterClient.IsLeader() {
s.updateDB(cfg, removedVersionId)
}
+4 -3
View File
@@ -109,9 +109,10 @@ func (h *SocketEventHandler) handleConfigSchema(conn etp.Conn, data []byte) []by
UpdatedAt: now,
}
upsertConfig := cluster.UpsertConfig{
Config: config,
Create: true,
Unsafe: true,
Config: config,
Create: true,
Unsafe: true,
VersionId: state.GenerateId(),
}
command := cluster.PrepareUpsertConfigCommand(upsertConfig)