diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b441d7..8e8b096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### upcoming +* add config version * add method `/module/broadcast_event` to broadcast arbitrary event to all connected modules ### v2.2.1 diff --git a/controller/config.go b/controller/config.go index 770ff0c..6ae7a39 100644 --- a/controller/config.go +++ b/controller/config.go @@ -67,7 +67,10 @@ func (c *config) CreateUpdateConfig(config domain.CreateUpdateConfigRequest) (*d Config: config.Config, Unsafe: config.Unsafe, } - if config.Id == "" { + if config.Id == "" || config.CreateNew { + if config.CreateNew { + upsertConfig.Config.Version++ + } upsertConfig.Config.Id = state.GenerateId() upsertConfig.Create = true } diff --git a/domain/request.go b/domain/request.go index 645bdca..16d84ab 100644 --- a/domain/request.go +++ b/domain/request.go @@ -30,5 +30,6 @@ type BroadcastEventRequest struct { type CreateUpdateConfigRequest struct { entity.Config - Unsafe bool + Unsafe bool + CreateNew bool } diff --git a/service/module_registry.go b/service/module_registry.go index 2c48e70..e61d746 100644 --- a/service/module_registry.go +++ b/service/module_registry.go @@ -131,9 +131,9 @@ func (moduleRegistryService) GetAggregatedModuleInfo(state state.ReadonlyState) Config: configs[i], Valid: false, }) - resMap[configs[i].ModuleId] = info } + schemas := state.Schemas().GetByModuleIds(idList) for _, s := range schemas { info := resMap[s.ModuleId] @@ -150,6 +150,9 @@ func (moduleRegistryService) GetAggregatedModuleInfo(state state.ReadonlyState) for key := range resMap { info := resMap[key] + sort.Slice(info.Configs, func(i, j int) bool { + return info.Configs[i].Version < info.Configs[j].Version + }) backends := state.Mesh().GetBackends(info.Name) conns := make([]domain.Connection, 0, len(backends))