forked from edgexfoundry/device-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
137 lines (127 loc) · 4.74 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
// -*- mode: Go; indent-tabs-mode: t -*-
//
// Copyright (C) 2017-2018 Canonical Ltd
// Copyright (C) 2018-2020 IOTech Ltd
// Copyright (c) 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
package common
import (
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
dsModels "github.com/edgexfoundry/go-mod-core-contracts/models"
)
// WritableInfo is a struct which contains configuration settings that can be changed in the Registry .
type WritableInfo struct {
// Level is the logging level of writing log message
LogLevel string
InsecureSecrets bootstrapConfig.InsecureSecrets
}
// ServiceInfo is a struct which contains service related configuration
// settings.
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
// Health check interval
CheckInterval string
// Host is the hostname or IP address of the service.
Host string
// Port is the HTTP port of the service.
Port int
// ServerBindAddr specifies an IP address or hostname
// for ListenAndServe to bind to, such as 0.0.0.0
ServerBindAddr string
// 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
// MaxResultCount specifies the maximum size list supported
// in response to REST calls to other services.
MaxResultCount int
// Timeout (in milliseconds) specifies both
// - timeout for processing REST calls and
// - interval time the DS will wait between each retry call.
Timeout int
// Labels are properties applied to the device service to help with searching
Labels []string
// EnableAsyncReadings to determine whether the Device Service would deal with the asynchronous readings
EnableAsyncReadings bool
// AsyncBufferSize defines the size of asynchronous channel
AsyncBufferSize int
}
// DeviceInfo is a struct which contains device specific configuration settings.
type DeviceInfo struct {
// DataTransform specifies whether or not the DS perform transformations
// specified by value descriptor on a actuation or query command.
DataTransform bool
// InitCmd specifies a device resource command which is automatically
// generated whenever a new device is added to the DS.
InitCmd string
// InitCmdArgs specify arguments to be used when building the InitCmd.
InitCmdArgs string
// MaxCmdOps defines the maximum number of resource operations that
// can be sent to a Driver in a single command.
MaxCmdOps int
// MaxCmdValueLen is the maximum string length of a command parameter or
// result (including the value descriptor name) that can be returned
// by a Driver.
MaxCmdValueLen int
// InitCmd specifies a device resource command which is automatically
// generated whenever a new device is removed from the DS.
RemoveCmd string
// RemoveCmdArgs specify arguments to be used when building the RemoveCmd.
RemoveCmdArgs string
// ProfilesDir specifies a directory which contains device profile
// files which should be imported on startup.
ProfilesDir string
// UpdateLastConnected specifies whether to update device's LastConnected
// timestamp in metadata.
UpdateLastConnected bool
Discovery DiscoveryInfo
}
// DiscoveryInfo is a struct which contains configuration of device auto discovery.
type DiscoveryInfo struct {
// Enabled controls whether or not device discovery is enabled.
Enabled bool
// Interval indicates how often the discovery process will be triggered.
// It represents as a duration string.
Interval string
}
// DeviceConfig is the definition of Devices which will be auto created when the Device Service starts up
type DeviceConfig struct {
// Name is the Device name
Name string
// Profile is the profile name of the Device
Profile string
// Description describes the device
Description string
// Other labels applied to the device to help with searching
Labels []string
// Protocols for the device - stores protocol properties
Protocols map[string]dsModels.ProtocolProperties
// AutoEvent supports auto-generated events sourced from a device service
AutoEvents []dsModels.AutoEvent
}
func (s ServiceInfo) GetBootstrapServiceInfo() bootstrapConfig.ServiceInfo {
return bootstrapConfig.ServiceInfo{
BootTimeout: s.BootTimeout,
CheckInterval: s.CheckInterval,
Host: s.Host,
Port: s.Port,
ServerBindAddr: s.ServerBindAddr,
Protocol: s.Protocol,
StartupMsg: s.StartupMsg,
MaxResultCount: s.MaxResultCount,
Timeout: s.Timeout,
}
}
// Telemetry provides metrics (on a given device service) to system management.
type Telemetry struct {
Alloc,
TotalAlloc,
Sys,
Mallocs,
Frees,
LiveObjects uint64
}