fix generate version id
This commit is contained in:
1 parent
6387947b22
commit
1c66729974
5 files changed
+16
-12
No files matched your search
+4
-3
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user