Skip to content

[Configuration] New APIs to simplify pull and updates  #101

@lenny-goodell

Description

@lenny-goodell

🚀 Tech Debt

Relevant Package [REQUIRED]

This feature request is for APIs to pull configuration and receive updated configuration (i.e. `Writable`) and the Consul implementation.

Per Napa planning this will not be included due to risk of destabilizing the release. Task for this release is to agree on the approach and possibly create a POC.

Description [REQUIRED]

The current APIs expect the service's complete config struct to be passed in when pulling config and waiting for updates. The Consul implementation uses `github.com/mitchellh/consulstructure` in both cases.

There are two issues with this approach:

  1. github.com/mitchellh/consulstructure doesn't support pull/marshaling slices.
  2. github.com/mitchellh/consulstructure updates the passed in service's config struct with the complete Writable section when a setting changes and doesn't provide indication of which settings have changed. With the need to merge configurations for the recent Common Config implementation, this has lead to this issue when map items are removed.

Describe the solution you'd like

  • Add new APIs (deprecate old versions) for pulling complete configuration and waiting for updates.
    • GetConfigurationMap() {map[string]any, error)
      This new API returns the service's complete configuration as a map which the caller can then use to merge/marshal into the service's config struct.
    • WatchForUpdates(updateChannel chan<- map[string]Update, errorChannel chan<- error, watchKey string)
      This new API will watch for updates, post a map containing only the fields that have changed. The setting paths are the map keys and the map values contain the new setting value and if the setting is existing, new or deleted (for handling of maps/slices).
  • Consul implementation would no longer use github.com/mitchellh/consulstructure. Instead would implement pulling/waiting internally. Long request on watchKey url for Updates and simple pull on root key for Get.

go-mod-bootstrap can then be refactored to use these new APIs to resolve edgexfoundry/go-mod-bootstrap#534 and enable slice as a type for configuration items.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestholdIntended for PRs we want to flag for ongoing review

    Type

    No type

    Projects

    Status

    Icebox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions