forked from edgexfoundry/edgex-go
/
types.go
157 lines (142 loc) · 4.95 KB
/
types.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
/*******************************************************************************
* Copyright 2018 Dell Inc.
*
* 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 config
import (
"fmt"
"github.com/jduranf/edgex-go/pkg/clients"
)
// ServiceInfo contains configuration settings necessary for the basic operation of any EdgeX service.
type ServiceInfo struct {
// BootTimeout indicates, in milliseconds, how long the service will retry connecting to upstream dependencies
// before giving up. Default is 30,000.
BootTimeout int
// Host is the hostname or IP address of the service.
Host string
// Port is the HTTP port of the service.
Port int
// The protocol that should be used to call this service
Protocol string
// StartupMsg specifies a string to log once service
// initialization and startup is completed.
StartupMsg string
// ReadMaxLimit specifies the maximum size list supported
// in response to REST calls to other services.
ReadMaxLimit int
// Timeout specifies a timeout (in milliseconds) for
// processing REST calls from other services.
Timeout int
}
// HealthCheck is a URL specifying a healthcheck REST endpoint used by the Registry to determine if the
// service is available.
func (s ServiceInfo) HealthCheck() string {
hc := fmt.Sprintf("%s://%s:%v%s", s.Protocol, s.Host, s.Port, clients.ApiPingRoute)
return hc
}
// Url provides a way to obtain the full url of the host service for use in initialization or, in some cases,
// responses to a caller.
func (s ServiceInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", s.Protocol, s.Host, s.Port)
return url
}
// LoggingInfo provides basic parameters related to where logs should be written.
type LoggingInfo struct {
EnableRemote bool
File string
}
// MessageQueueInfo provides parameters related to connecting to a message queue
type MessageQueueInfo struct {
// Host is the hostname or IP address of the broker, if applicable.
Host string
// Port defines the port on which to access the message queue.
Port int
// Protocol indicates the protocol to use when accessing the message queue.
Protocol string
// Indicates the message queue platform being used.
Type string
}
func (m MessageQueueInfo) Uri() string {
uri := fmt.Sprintf("%s://%s:%v", m.Protocol, m.Host, m.Port)
return uri
}
// DatabaseInfo defines the parameters necessary for connecting to the desired persistence layer.
type DatabaseInfo struct {
Type string
Timeout int
Host string
Port int
Username string
Password string
Name string
}
type IntervalInfo struct {
// Name of the schedule must be unique?
Name string
// Start time in ISO 8601 format YYYYMMDD'T'HHmmss
Start string
// End time in ISO 8601 format YYYYMMDD'T'HHmmss
End string
// Periodicity of the schedule
Frequency string
// Cron style regular expression indicating how often the action under schedule should occur. Use either runOnce, frequency or cron and not all.
Cron string
// Boolean indicating that this schedules runs one time - at the time indicated by the start
RunOnce bool
}
type IntervalActionInfo struct {
// Host is the hostname or IP address of a service.
Host string
// Port defines the port on which to access a given service
Port int
// Protocol indicates the protocol to use when accessing a given service
Protocol string
// Action name
Name string
// Action http method *const prob*
Method string
// Acton target name
Target string
// Action target parameters
Parameters string
// Action target API path
Path string
// Associated Schedule for the Event
Interval string
}
// ScheduleEventInfo helper function
func (e IntervalActionInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", e.Protocol, e.Host, e.Port)
return url
}
// ClientInfo provides the host and port of another service in the eco-system.
type ClientInfo struct {
// Host is the hostname or IP address of a service.
Host string
// Port defines the port on which to access a given service
Port int
// Protocol indicates the protocol to use when accessing a given service
Protocol string
}
func (c ClientInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", c.Protocol, c.Host, c.Port)
return url
}
// Notification Info provides properties related to the assembly of notification content
type NotificationInfo struct {
Content string
Description string
Label string
PostDeviceChanges bool
Sender string
Slug string
}