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

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 committed Feb 3, 2021
1 parent 7097895 commit 9aacd00
Showing 1 changed file with 14 additions and 1 deletion.
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 9aacd00

Please sign in to comment.