export-distro是EDGEX系统中数据转发服务,export-distro使用介绍如下,他有2个启动参数可以配置:
- registry是一个bool量,True表示export-distro的配置参数是从consul拉取,False表示从本地配置文件载入。
- profile本地配置文件的路径, 即便registry=True, 该参数也必须要指明一个配置文件,因为连接consul服务所需的host,port等参数必须从本地的配置文件中获取。
Usage: %s [options]
Server Options:
-r, --registry Indicates service should use Registry
-p, --profile <name> Indicate configuration profile other than default
Common Options:
-h, --help Show this message
export-distro的配置文件
[Writable]
MarkPushed = false
LogLevel = 'INFO'
[Service]
BootTimeout = 30000
ClientMonitor = 15000
CheckInterval = '10s'
Host = 'localhost'
Port = 48070
Protocol = 'http'
ReadMaxLimit = 100
StartupMsg = 'This is the Export Distro Microservice'
Timeout = 5000
[Registry]
Host = 'localhost'
Port = 8500
Type = 'consul'
[Logging]
EnableRemote = false
File = './logs/edgex-export-distro.log'
[Clients]
[Clients.Export]
Protocol = 'http'
Host = 'localhost'
Port = 48071
[Clients.Logging]
Protocol = 'http'
Host = 'localhost'
Port = 48061
[Clients.CoreData]
Protocol = 'http'
Host = 'localhost'
Port = 48080
[Certificates]
[Certificates.MQTTS]
Cert = 'dummy.crt'
Key = 'dummy.key'
[Certificates.AWS]
Cert = 'dummy.crt'
Key = 'dummy.key'
[MessageQueue]
Protocol = 'tcp'
Host = 'localhost'
Port = 5563
Type = 'zero'
Topic = 'events'
[AnalyticsQueue]
Protocol = 'tcp'
Host = '*'
Port = 5566
Type = 'zero'
如上是项目自带的export-distro的配置文件 ,主要分8部分,export-distro启动后会将配置文件的信息导入如下结构中,若registry=True则根据Registry中的信息连接consul并拉取相应的配置信息覆盖之前从本地配置文件中读取到的信息。
type ConfigurationStruct struct {
Writable WritableInfo
Certificates map[string]CertificateInfo
Clients map[string]config.ClientInfo
Logging config.LoggingInfo
MessageQueue config.MessageQueueInfo
AnalyticsQueue config.MessageQueueInfo
Registry config.RegistryInfo
Service config.ServiceInfo
}
Writable
type WritableInfo struct {
MarkPushed bool
LogLevel string
}
MarkPushed 是否提供数据成功转发后的通知,如果使能,那么AnalysticsQueue必须设置
LogLevel 日志等级
Clients
// 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
}
Host 微服务的地址
Port 微服务的端口
Protocol 微服务所使用的协议,目前仅支持http
export-client运行时需要使用其他微服务提供的功能,Client便是连接其他微服务所必须的参数,这是一个map参数,key值便是其他微服务的名字,value便是client的具体参数信息, export-client正常运行一般需要使用logging, core-data和export-client三个微服务。
Logging
// LoggingInfo provides basic parameters related to where logs should be written.
type LoggingInfo struct {
EnableRemote bool
File string
}
EnableRemote True: log于support-logging微服务持久化(support-logging的连接参数由Clients字段提供), False:log于本地文件持久化
File log本地持久化时日志文件的路径
Registry
// RegistryInfo defines the type and location (via host/port) of the desired service registry (e.g. Consul, Eureka)
type RegistryInfo struct {
Host string
Port int
Type string
}
consul连接参数
MessageQueue
// 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
// Indicates the topic the data is published/subscribed
Topic string
}
export-distro是消息队列的消费者,生产者是core-data. 因此该字段的内容与core-data中相应字段含义相同。
AnalyticsQueue
// 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
// Indicates the topic the data is published/subscribed
Topic string
}
处理后的消息成功转发后的通知消息发布,此处为生产者,字段含义同上
Certificates
type CertificateInfo struct {
Cert string
Key string
}
一般接收EdgeX转发数据的外部系统是IOT平台如AWS的IOT平台,这些平台接受数据的时候需要提供对应的秘钥文件,该字段就是这些文件,当然外部系统也可以是其他接口兼容的服务。