Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): Add helper to query DIC and returns the DeviceServiceCommandClient instance #162

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}