Skip to content

Commit

Permalink
Merge pull request #165 from jinlinGuan/issue-4985
Browse files Browse the repository at this point in the history
feat!: Remove consul dependency
  • Loading branch information
cloudxxx8 authored Oct 30, 2024
2 parents dfec6cf + 5172b78 commit 4f49fe4
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 1,827 deletions.
5 changes: 0 additions & 5 deletions configuration/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package configuration
import (
"fmt"

"github.com/edgexfoundry/go-mod-configuration/v4/internal/pkg/consul"
"github.com/edgexfoundry/go-mod-configuration/v4/internal/pkg/keeper"
"github.com/edgexfoundry/go-mod-configuration/v4/pkg/types"
)
Expand All @@ -32,10 +31,6 @@ func NewConfigurationClient(config types.ServiceConfig) (Client, error) {
}

switch config.Type {
case "consul":
var err error
client, err := consul.NewConsulClient(config)
return client, err
case "keeper":
client := keeper.NewKeeperClient(config)
return client, nil
Expand Down
9 changes: 3 additions & 6 deletions configuration/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ var config = types.ServiceConfig{
BasePath: "config",
}

func TestNewClientConsul(t *testing.T) {
func TestNewClientKeeper(t *testing.T) {

config.Type = "consul"

client, err := NewConfigurationClient(config)
config.Type = "keeper"
_, err := NewConfigurationClient(config)
if assert.Nil(t, err, "New Configuration client failed: ", err) == false {
t.Fatal()
}

assert.False(t, client.IsAlive(), "Consul service not expected be running")
}

func TestNewClientBogusType(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions configuration/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ type Client interface {
// PutConfiguration puts a full configuration struct into the Configuration service
PutConfiguration(configStruct interface{}, overwrite bool) error

// GetConfiguration gets the full configuration from Consul into the target configuration struct.
// GetConfiguration gets the full configuration from keeper into the target configuration struct.
// Passed in struct is only a reference for Configuration service. Empty struct is fine
// Returns the configuration in the target struct as interface{}, which caller must cast
GetConfiguration(configStruct interface{}) (interface{}, error)

// WatchForChanges sets up a Consul watch for the target key and send back updates on the update channel.
// WatchForChanges sets up a keeper watch for the target key and send back updates on the update channel.
// Passed in struct is only a reference for Configuration service, empty struct is ok
// Sends the configuration in the target struct as interface{} on updateChannel, which caller must cast
WatchForChanges(updateChannel chan<- interface{}, errorChannel chan<- error, configuration interface{}, waitKey string, msgClient messaging.MessageClient)
Expand Down
22 changes: 3 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ module github.com/edgexfoundry/go-mod-configuration/v4
go 1.23

require (
github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.1
github.com/edgexfoundry/go-mod-messaging/v4 v4.0.0-dev.1
github.com/hashicorp/consul/api v1.29.4
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54
github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.2
github.com/edgexfoundry/go-mod-messaging/v4 v4.0.0-dev.3
github.com/mitchellh/mapstructure v1.5.0
github.com/spf13/cast v1.7.0
github.com/stretchr/testify v1.9.0
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/eclipse/paho.mqtt.golang v1.5.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
Expand All @@ -27,20 +22,9 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/nats-io/nats.go v1.37.0 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
Expand All @@ -49,11 +33,11 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.2.5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4f49fe4

Please sign in to comment.