From 372c4713d174a44dd33b230e8bde9a98f555bc4f Mon Sep 17 00:00:00 2001 From: Chris Hung Date: Fri, 3 Feb 2023 11:09:02 +0800 Subject: [PATCH] feat(metadata)!: remove Notifications config BREAKING CHANGE: Removed the 'Notifications' config and 'Clients.support-notifications' dependency in EdgeX 3.0, metadata will leverage device system events to replace the original device change notifications closes #4316 Signed-off-by: Chris Hung --- cmd/core-metadata/res/configuration.toml | 13 ----------- internal/core/metadata/config/config.go | 25 +++++--------------- internal/core/metadata/main.go | 29 ++++-------------------- 3 files changed, 10 insertions(+), 57 deletions(-) diff --git a/cmd/core-metadata/res/configuration.toml b/cmd/core-metadata/res/configuration.toml index 2b229a8f0d..971a9725b7 100644 --- a/cmd/core-metadata/res/configuration.toml +++ b/cmd/core-metadata/res/configuration.toml @@ -49,12 +49,6 @@ Host = "localhost" Port = 8500 Type = "consul" -[Clients] - [Clients.support-notifications] - Protocol = "http" - Host = "localhost" - Port = 59860 - [Database] Host = "localhost" Name = "metadata" @@ -62,13 +56,6 @@ Port = 6379 Timeout = 5000 Type = "redisdb" -[Notifications] -PostDeviceChanges = false -Content = "Metadata notice: " -Sender = "core-metadata" -Description = "Metadata change notice" -Label = "metadata" - [MessageBus] Protocol = "redis" Host = "localhost" diff --git a/internal/core/metadata/config/config.go b/internal/core/metadata/config/config.go index aac21e7216..863cfecf30 100644 --- a/internal/core/metadata/config/config.go +++ b/internal/core/metadata/config/config.go @@ -20,14 +20,12 @@ import ( // Struct used to parse the JSON configuration file type ConfigurationStruct struct { - Writable WritableInfo - Clients map[string]bootstrapConfig.ClientInfo - Database bootstrapConfig.Database - Notifications NotificationInfo - Registry bootstrapConfig.RegistryInfo - Service bootstrapConfig.ServiceInfo - MessageBus bootstrapConfig.MessageBusInfo - UoM UoM + Writable WritableInfo + Database bootstrapConfig.Database + Registry bootstrapConfig.RegistryInfo + Service bootstrapConfig.ServiceInfo + MessageBus bootstrapConfig.MessageBusInfo + UoM UoM } type WritableInfo struct { @@ -51,16 +49,6 @@ type UoM struct { UoMFile string } -// NotificationInfo provides properties related to the assembly of notification content -type NotificationInfo struct { - Content string - Description string - Label string - PostDeviceChanges bool - Sender string - Slug string -} - // UpdateFromRaw converts configuration received from the registry to a service-specific configuration struct which is // then used to overwrite the service's existing configuration struct. func (c *ConfigurationStruct) UpdateFromRaw(rawConfig interface{}) bool { @@ -98,7 +86,6 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration { // temporary until we can make backwards-breaking configuration.toml change return bootstrapConfig.BootstrapConfiguration{ - Clients: c.Clients, Service: c.Service, Registry: c.Registry, MessageBus: c.MessageBus, diff --git a/internal/core/metadata/main.go b/internal/core/metadata/main.go index e1a0c901c5..17cecd3015 100644 --- a/internal/core/metadata/main.go +++ b/internal/core/metadata/main.go @@ -58,14 +58,13 @@ func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router) { httpServer := handlers.NewHttpServer(router, true) - wg, deferred, success := bootstrap.RunAndReturnWaitGroup( + bootstrap.Run( ctx, cancel, f, common.CoreMetaDataServiceKey, common.ConfigStemCore, configuration, - nil, startupTimer, dic, true, @@ -76,27 +75,7 @@ func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router) { handlers.NewServiceMetrics(common.CoreMetaDataServiceKey).BootstrapHandler, // Must be after Messaging NewBootstrap(router, common.CoreMetaDataServiceKey).BootstrapHandler, httpServer.BootstrapHandler, - }) - - if !success { - return - } - - // Have to call this handler outside the bootstrapping when configuration is loaded and known - configuration = container.ConfigurationFrom(dic.Get) - // Only create Notifications Client if going to be using it - if configuration.Notifications.PostDeviceChanges { - if !handlers.NewClientsBootstrap().BootstrapHandler(ctx, wg, startupTimer, dic) { - return - } - } - - // Call this handler outside the bootstrapping, so it is always last. - handlers.NewStartMessage(common.CoreMetaDataServiceKey, edgex.Version).BootstrapHandler(ctx, wg, startupTimer, dic) - - wg.Wait() - - if deferred != nil { - deferred() - } + handlers.NewStartMessage(common.CoreMetaDataServiceKey, edgex.Version).BootstrapHandler, + }, + ) }