Skip to content

Commit

Permalink
feat(v2): Add helper to query DIC and returns the DeviceServiceComman…
Browse files Browse the repository at this point in the history
…dClient instance (#162)

DeviceServiceCommandClient was added into go-mod-core-contracts, and we shall have corresponding helper function in go-mod-bootstrap to query DIC and then return the DeviceServiceCommandClient instance

Signed-off-by: Jude Hung <[email protected]>
  • Loading branch information
judehung authored Feb 3, 2021
1 parent 7097895 commit c087e44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/edgexfoundry/go-mod-bootstrap/v2
require (
github.com/BurntSushi/toml v0.3.1
github.com/edgexfoundry/go-mod-configuration/v2 v2.0.0-dev.1
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.0.0-dev.13
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.0.0-dev.18
github.com/edgexfoundry/go-mod-registry/v2 v2.0.0-dev.1
github.com/edgexfoundry/go-mod-secrets/v2 v2.0.0-dev.3
github.com/gorilla/mux v1.7.1
Expand Down
15 changes: 14 additions & 1 deletion v2/bootstrap/container/deviceservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
// DeviceServiceCallbackClientName contains the name of the DeviceServiceCallbackClient instance in the DIC.
var DeviceServiceCallbackClientName = di.TypeInstanceToName((*interfaces.DeviceServiceCallbackClient)(nil))

// DeviceServiceCallbackClientFrom helper function queries the DIC and returns the DeviceServiceCallbackClientFrom instance.
// DeviceServiceCommandClientName contains the name of the DeviceServiceCommandClient instance in the DIC.
var DeviceServiceCommandClientName = di.TypeInstanceToName((*interfaces.DeviceServiceCommandClient)(nil))

// DeviceServiceCallbackClientFrom helper function queries the DIC and returns the DeviceServiceCallbackClient instance.
func DeviceServiceCallbackClientFrom(get di.Get) interfaces.DeviceServiceCallbackClient {
client, ok := get(DeviceServiceCallbackClientName).(interfaces.DeviceServiceCallbackClient)
if !ok {
Expand All @@ -22,3 +25,13 @@ func DeviceServiceCallbackClientFrom(get di.Get) interfaces.DeviceServiceCallbac

return client
}

// DeviceServiceCommandClientFrom helper function queries the DIC and returns the DeviceServiceCommandClient instance.
func DeviceServiceCommandClientFrom(get di.Get) interfaces.DeviceServiceCommandClient {
client, ok := get(DeviceServiceCommandClientName).(interfaces.DeviceServiceCommandClient)
if !ok {
return nil
}

return client
}

0 comments on commit c087e44

Please sign in to comment.