-
Notifications
You must be signed in to change notification settings - Fork 52
/
clients.go
181 lines (139 loc) · 7 KB
/
clients.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//
// Copyright (c) 2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package container
import (
"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/interfaces"
"github.com/edgexfoundry/go-mod-bootstrap/v3/di"
)
// EventClientName contains the name of the EventClient's implementation in the DIC.
var EventClientName = di.TypeInstanceToName((*interfaces.EventClient)(nil))
// EventClientFrom helper function queries the DIC and returns the EventClient's implementation.
func EventClientFrom(get di.Get) interfaces.EventClient {
if get(EventClientName) == nil {
return nil
}
return get(EventClientName).(interfaces.EventClient)
}
// ReadingClientName contains the name of the ReadingClient instance in the DIC.
var ReadingClientName = di.TypeInstanceToName((*interfaces.ReadingClient)(nil))
// ReadingClientFrom helper function queries the DIC and returns the ReadingClient instance.
func ReadingClientFrom(get di.Get) interfaces.ReadingClient {
client, ok := get(ReadingClientName).(interfaces.ReadingClient)
if !ok {
return nil
}
return client
}
// CommandClientName contains the name of the CommandClient's implementation in the DIC.
var CommandClientName = di.TypeInstanceToName((*interfaces.CommandClient)(nil))
// CommandClientFrom helper function queries the DIC and returns the CommandClient's implementation.
func CommandClientFrom(get di.Get) interfaces.CommandClient {
if get(CommandClientName) == nil {
return nil
}
return get(CommandClientName).(interfaces.CommandClient)
}
// NotificationClientName contains the name of the NotificationClient's implementation in the DIC.
var NotificationClientName = di.TypeInstanceToName((*interfaces.NotificationClient)(nil))
// NotificationClientFrom helper function queries the DIC and returns the NotificationClient's implementation.
func NotificationClientFrom(get di.Get) interfaces.NotificationClient {
if get(NotificationClientName) == nil {
return nil
}
return get(NotificationClientName).(interfaces.NotificationClient)
}
// SubscriptionClientName contains the name of the SubscriptionClient's implementation in the DIC.
var SubscriptionClientName = di.TypeInstanceToName((*interfaces.SubscriptionClient)(nil))
// SubscriptionClientFrom helper function queries the DIC and returns the SubscriptionClient's implementation.
func SubscriptionClientFrom(get di.Get) interfaces.SubscriptionClient {
if get(SubscriptionClientName) == nil {
return nil
}
return get(SubscriptionClientName).(interfaces.SubscriptionClient)
}
// DeviceServiceClientName contains the name of the DeviceServiceClient's implementation in the DIC.
var DeviceServiceClientName = di.TypeInstanceToName((*interfaces.DeviceServiceClient)(nil))
// DeviceServiceClientFrom helper function queries the DIC and returns the DeviceServiceClient's implementation.
func DeviceServiceClientFrom(get di.Get) interfaces.DeviceServiceClient {
if get(DeviceServiceClientName) == nil {
return nil
}
return get(DeviceServiceClientName).(interfaces.DeviceServiceClient)
}
// DeviceProfileClientName contains the name of the DeviceProfileClient's implementation in the DIC.
var DeviceProfileClientName = di.TypeInstanceToName((*interfaces.DeviceProfileClient)(nil))
// DeviceProfileClientFrom helper function queries the DIC and returns the DeviceProfileClient's implementation.
func DeviceProfileClientFrom(get di.Get) interfaces.DeviceProfileClient {
if get(DeviceProfileClientName) == nil {
return nil
}
return get(DeviceProfileClientName).(interfaces.DeviceProfileClient)
}
// DeviceClientName contains the name of the DeviceClient's implementation in the DIC.
var DeviceClientName = di.TypeInstanceToName((*interfaces.DeviceClient)(nil))
// DeviceClientFrom helper function queries the DIC and returns the DeviceClient's implementation.
func DeviceClientFrom(get di.Get) interfaces.DeviceClient {
if get(DeviceClientName) == nil {
return nil
}
return get(DeviceClientName).(interfaces.DeviceClient)
}
// ProvisionWatcherClientName contains the name of the ProvisionWatcherClient's implementation in the DIC.
var ProvisionWatcherClientName = di.TypeInstanceToName((*interfaces.ProvisionWatcherClient)(nil))
// ProvisionWatcherClientFrom helper function queries the DIC and returns the ProvisionWatcherClient's implementation.
func ProvisionWatcherClientFrom(get di.Get) interfaces.ProvisionWatcherClient {
if get(ProvisionWatcherClientName) == nil {
return nil
}
return get(ProvisionWatcherClientName).(interfaces.ProvisionWatcherClient)
}
// IntervalClientName contains the name of the IntervalClient's implementation in the DIC.
var IntervalClientName = di.TypeInstanceToName((*interfaces.IntervalClient)(nil))
// IntervalClientFrom helper function queries the DIC and returns the IntervalClient's implementation.
func IntervalClientFrom(get di.Get) interfaces.IntervalClient {
if get(IntervalClientName) == nil {
return nil
}
return get(IntervalClientName).(interfaces.IntervalClient)
}
// IntervalActionClientName contains the name of the IntervalActionClient's implementation in the DIC.
var IntervalActionClientName = di.TypeInstanceToName((*interfaces.IntervalActionClient)(nil))
// IntervalActionClientFrom helper function queries the DIC and returns the IntervalActionClient's implementation.
func IntervalActionClientFrom(get di.Get) interfaces.IntervalActionClient {
if get(IntervalActionClientName) == nil {
return nil
}
return get(IntervalActionClientName).(interfaces.IntervalActionClient)
}
// DeviceServiceCallbackClientName contains the name of the DeviceServiceCallbackClient instance in the DIC.
var DeviceServiceCallbackClientName = di.TypeInstanceToName((*interfaces.DeviceServiceCallbackClient)(nil))
// 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 {
return nil
}
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
}