-
Notifications
You must be signed in to change notification settings - Fork 55
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): Create Helper functions to retrieve client library instances through DIC #158
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package container | ||
|
||
import ( | ||
"github.com/edgexfoundry/go-mod-bootstrap/v2/di" | ||
v2Clients "github.com/edgexfoundry/go-mod-core-contracts/v2/v2/clients/interfaces" | ||
) | ||
|
||
// CommonClientName contains the name of the CommonClient instance in the DIC. | ||
var CommonClientName = "V2CommonClient" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use this form of creating the name for all these containers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Modified through d642159 |
||
|
||
// CommonClientFrom helper function queries the DIC and returns the CommonClient instance. | ||
func CommonClientFrom(get di.Get) v2Clients.CommonClient { | ||
return get(CommonClientName).(v2Clients.CommonClient) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the pattern here so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Modified through d642159 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package container | ||
|
||
import ( | ||
"github.com/edgexfoundry/go-mod-bootstrap/v2/di" | ||
v2Clients "github.com/edgexfoundry/go-mod-core-contracts/v2/v2/clients/interfaces" | ||
) | ||
|
||
// DataEventClientName contains the name of the EventClient instance in the DIC. | ||
var DataEventClientName = "V2DataEventClient" | ||
|
||
// DataReadingClientName contains the name of the ReadingClient instance in the DIC. | ||
var DataReadingClientName = "V2DataReadingClient" | ||
|
||
// DataEventClientFrom helper function queries the DIC and returns the EventClient instance. | ||
func DataEventClientFrom(get di.Get) v2Clients.EventClient { | ||
return get(DataEventClientName).(v2Clients.EventClient) | ||
} | ||
|
||
// DataReadingClientFrom helper function queries the DIC and returns the ReadingClient instance. | ||
func DataReadingClientFrom(get di.Get) v2Clients.ReadingClient { | ||
return get(DataReadingClientName).(v2Clients.ReadingClient) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package container | ||
|
||
import ( | ||
"github.com/edgexfoundry/go-mod-bootstrap/v2/di" | ||
v2Clients "github.com/edgexfoundry/go-mod-core-contracts/v2/v2/clients/interfaces" | ||
) | ||
|
||
// DeviceServiceCallbackClientName contains the name of the DeviceServiceCallbackClient instance in the DIC. | ||
var DeviceServiceCallbackClientName = "V2DeviceServiceCallbackClient" | ||
|
||
// DeviceServiceCallbackClientFrom helper function queries the DIC and returns the DeviceServiceCallbackClientFrom instance. | ||
func DeviceServiceCallbackClientFrom(get di.Get) v2Clients.DeviceServiceCallbackClient { | ||
return get(DeviceServiceCallbackClientName).(v2Clients.DeviceServiceCallbackClient) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package container | ||
|
||
import ( | ||
"github.com/edgexfoundry/go-mod-bootstrap/v2/di" | ||
v2Clients "github.com/edgexfoundry/go-mod-core-contracts/v2/v2/clients/interfaces" | ||
) | ||
|
||
// MetadataDeviceClientName contains the name of the Metadata DeviceClient instance in the DIC. | ||
var MetadataDeviceClientName = "V2MetadataDeviceClient" | ||
|
||
// MetadataDeviceProfileClientName contains the name of the Metadata DeviceProfileClient instance in the DIC. | ||
var MetadataDeviceProfileClientName = "V2MetadataDeviceProfileClient" | ||
|
||
// MetadataDeviceServiceClientName contains the name of the Metadata DeviceServiceClient instance in the DIC. | ||
var MetadataDeviceServiceClientName = "V2MetadataDeviceServiceClient" | ||
|
||
// MetadataProvisionWatcherClientName contains the name of the Metadata ProvisionWatcherClient instance in the DIC. | ||
var MetadataProvisionWatcherClientName = "V2MetadataProvisionWatcherClient" | ||
|
||
// MetadataDeviceClientFrom helper function queries the DIC and returns the Metadata DeviceClient instance. | ||
func MetadataDeviceClientFrom(get di.Get) v2Clients.DeviceClient { | ||
return get(MetadataDeviceClientName).(v2Clients.DeviceClient) | ||
} | ||
|
||
// MetadataDeviceProfileClientFrom helper function queries the DIC and returns the Metadata DeviceProfileClient instance. | ||
func MetadataDeviceProfileClientFrom(get di.Get) v2Clients.DeviceProfileClient { | ||
return get(MetadataDeviceProfileClientName).(v2Clients.DeviceProfileClient) | ||
} | ||
|
||
// MetadataDeviceServiceClientFrom helper function queries the DIC and returns the Metadata DeviceServiceClient instance. | ||
func MetadataDeviceServiceClientFrom(get di.Get) v2Clients.DeviceServiceClient { | ||
return get(MetadataDeviceServiceClientName).(v2Clients.DeviceServiceClient) | ||
} | ||
|
||
// MetadataProvisionWatcherClientFrom helper function queries the DIC and returns the Metadata ProvisionWatcherClient instance. | ||
func MetadataProvisionWatcherClientFrom(get di.Get) v2Clients.ProvisionWatcherClient { | ||
return get(MetadataProvisionWatcherClientName).(v2Clients.ProvisionWatcherClient) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't alias package unless it is needed to resolve name collision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed alias. d642159