Skip to content

Commit

Permalink
Merge pull request #4320 from hahattan/issue-4316
Browse files Browse the repository at this point in the history
feat(metadata)!: remove Notifications config
  • Loading branch information
cloudxxx8 committed Feb 7, 2023
2 parents 6d90133 + 372c471 commit c283a7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 57 deletions.
13 changes: 0 additions & 13 deletions cmd/core-metadata/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,13 @@ Host = "localhost"
Port = 8500
Type = "consul"

[Clients]
[Clients.support-notifications]
Protocol = "http"
Host = "localhost"
Port = 59860

[Database]
Host = "localhost"
Name = "metadata"
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"
Expand Down
25 changes: 6 additions & 19 deletions internal/core/metadata/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
29 changes: 4 additions & 25 deletions internal/core/metadata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
)
}

0 comments on commit c283a7b

Please sign in to comment.