EDGEX FOUNDRY配置参数 --- core-command

core-command是向设备发送命令的微服务,他自己提供接口接收来自其他微服务的命令并将该命令发送到相应的设备微服务从而间接的将该命令下发到过载在该设备微服务的具体物理设备上,core-command使用介绍如下,他有2个启动参数可以配置:

  • registry是一个bool量,True表示core-command的配置参数是从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

Table of Contents

 core-command的配置文件

Writable 

Clients  

Databases

Logging  

Registry 

Service  


 core-command的配置文件

[Writable]
LogLevel = 'INFO'

[Service]
BootTimeout = 30000
ClientMonitor = 15000
CheckInterval = '10s'
Host = 'localhost'
Port = 48082
Protocol = 'http'
ReadMaxLimit = 100
StartupMsg = 'This is the Core Command Microservice'
Timeout = 5000

[Registry]
Host = 'localhost'
Port = 8500
Type = 'consul'

[Logging]
EnableRemote = false
File = './logs/edgex-core-command.log'

[Clients]
  [Clients.Metadata]
  Protocol = 'http'
  Host = 'localhost'
  Port = 48081

  [Clients.Logging]
  Protocol = 'http'
  Host = 'localhost'
  Port = 48061

 如上是项目自带的core-command的配置文件 ,主要分5部分,core-command启动后会将配置文件的信息导入如下结构中,若registry=True则根据Registry中的信息连接consul并拉取相应的配置信息覆盖之前从本地配置文件中读取到的信息。

type ConfigurationStruct struct {
	Writable  WritableInfo
	Clients   map[string]config.ClientInfo
	Databases map[string]config.DatabaseInfo
	Logging   config.LoggingInfo
	Registry  config.RegistryInfo
	Service   config.ServiceInfo
}

虽然这个结构体与support-logging中的配置结构体很相似或者完全一样,但是他们实际上是代码独立编码的,这点后面介绍的微服务也一样会有这个现象,仔细观察他们实际上还是有差别的。

Writable 

type WritableInfo struct {
	LogLevel  string
}
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
}

core-command运行时需要使用其他微服务提供的功能,Client便是连接其他微服务所必须的参数,这是一个map参数,key值便是其他微服务的名字,value便是client的具体参数信息: 

Host 微服务的地址
Port 微服务的端口
Protocol 微服务所使用的协议,目前仅支持http


Databases

core-command微服务没有使用任何数据库,该字段目前未被使用。


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连接参数 


Service  

同support-logging

猜你喜欢

转载自blog.csdn.net/keyoushide/article/details/89480281