up created_at for version_config
This commit is contained in:
1 parent
a3576cc3f4
commit
8bdc36a302
5 files changed
+21
-14
No files matched your search
+5
-4
@@ -28,10 +28,11 @@ type ActivateConfig struct {
|
||||
}
|
||||
|
||||
type UpsertConfig struct {
|
||||
Config entity.Config
|
||||
VersionId string
|
||||
Create bool
|
||||
Unsafe bool
|
||||
Config entity.Config
|
||||
VersionId string
|
||||
VersionCreateAt time.Time
|
||||
Create bool
|
||||
Unsafe bool
|
||||
}
|
||||
|
||||
type DeleteConfigs struct {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -64,9 +66,10 @@ func (c *config) CreateUpdateConfig(config domain.CreateUpdateConfigRequest) (*d
|
||||
config.CreatedAt = now
|
||||
config.UpdatedAt = now
|
||||
upsertConfig := cluster.UpsertConfig{
|
||||
Config: config.Config,
|
||||
Unsafe: config.Unsafe,
|
||||
VersionId: state.GenerateId(),
|
||||
Config: config.Config,
|
||||
Unsafe: config.Unsafe,
|
||||
VersionId: state.GenerateId(),
|
||||
VersionCreateAt: time.Now().UTC(),
|
||||
}
|
||||
if config.Id == "" {
|
||||
upsertConfig.Config.Id = state.GenerateId()
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ func (cs configService) HandleUpsertConfigCommand(upsertConfig cluster.UpsertCon
|
||||
config.Version = oldCfg.Version + 1
|
||||
state.WritableConfigs().UpdateById(config)
|
||||
|
||||
ConfigHistory.SaveConfigVersion(upsertConfig.VersionId, oldCfg, state)
|
||||
ConfigHistory.SaveConfigVersion(upsertConfig.VersionId, oldCfg, state, upsertConfig.VersionCreateAt)
|
||||
}
|
||||
|
||||
if holder.ClusterClient.IsLeader() {
|
||||
|
||||
+3
-2
@@ -42,13 +42,14 @@ func (configHistoryService) GetAllVersionConfigById(id string, state state.Reado
|
||||
return state.VersionConfig().GetByConfigId(id)
|
||||
}
|
||||
|
||||
func (s configHistoryService) SaveConfigVersion(id string, oldConfig entity.Config, state state.WritableState) {
|
||||
func (s configHistoryService) SaveConfigVersion(id string, oldConfig entity.Config,
|
||||
state state.WritableState, createdAt time.Time) {
|
||||
cfg := entity.VersionConfig{
|
||||
Id: id,
|
||||
ConfigVersion: oldConfig.Version,
|
||||
ConfigId: oldConfig.Id,
|
||||
Data: oldConfig.Data,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
CreatedAt: createdAt,
|
||||
}
|
||||
removedVersionId := state.WriteableVersionConfigStore().Update(cfg)
|
||||
if holder.ClusterClient.IsLeader() {
|
||||
|
||||
+6
-4
@@ -2,6 +2,7 @@ package subs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
etp "github.com/integration-system/isp-etp-go/v2"
|
||||
@@ -109,10 +110,11 @@ func (h *SocketEventHandler) handleConfigSchema(conn etp.Conn, data []byte) []by
|
||||
UpdatedAt: now,
|
||||
}
|
||||
upsertConfig := cluster.UpsertConfig{
|
||||
Config: config,
|
||||
Create: true,
|
||||
Unsafe: true,
|
||||
VersionId: state.GenerateId(),
|
||||
Config: config,
|
||||
Create: true,
|
||||
Unsafe: true,
|
||||
VersionId: state.GenerateId(),
|
||||
VersionCreateAt: time.Now().UTC(),
|
||||
}
|
||||
|
||||
command := cluster.PrepareUpsertConfigCommand(upsertConfig)
|
||||
|
||||
Reference in new issue
Block a user