EDGEX FOUNDRY配置参数 --- support-notifications

support-notifications是主要是EDGEX系统中的提醒服务,support-notifications使用介绍如下,他有2个启动参数可以配置:

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

 support-notifications的配置文件

Writable 

Clients  

Databases

Logging  

Registry 

Service  

Smtp


support-notifications的配置文件

[Writable]
ResendLimit = 2
LogLevel = 'INFO'

[Service]
BootTimeout = 30000
ClientMonitor = 15000
CheckInterval = '10s'
Host = 'localhost'
Port = 48060
Protocol = 'http'
ReadMaxLimit = 1000
StartupMsg = 'This is the Support Notifications Microservice'
Timeout = 5000

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

[Logging]
EnableRemote = false
File = './logs/edgex-support-notifications.log'

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

[Databases]
  [Databases.Primary]
  Host = 'localhost'
  Name = 'notifications'
  Password = ''
  Port = 27017
  Username = ''
  Timeout = 5000
  Type = 'mongodb'

[Smtp]
Host = 'smtp.gmail.com'
Password = 'mypassword'
Port = 587
Sender = '[email protected]'
Subject = 'EdgeX Notification'

 如上是项目自带的support-notifications的配置文件 ,主要分7部分,support-notifications启动后会将配置文件的信息导入如下结构中,若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
	Smtp        SmtpInfo
}

Writable 

type WritableInfo struct {
	ResendLimit int
	LogLevel    string
}

support-notifications有2个参数可以在运行时被修改 

ResendLimit send失败后重试次数,比如notification现在要给某个邮件地址发送提醒,但是由于未知原因发送失败,系统会尝试每隔5秒重复发送,重复的最大次数就是ResendLimit 
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

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

Databases

type DatabaseInfo struct {
	Type     string
	Timeout  int
	Host     string
	Port     int
	Username string
	Password string
	Name     string
}
Type     数据库类型,目前仅支持 mongodb
Timeout  数据库连接超时,单位:s
Host     数据库地址
Port     数据库端口
Username 数据库登录用户名
Password 数据库登录密码
Name     数据库名字

与support-logging相同,support-notifications当前仅支持一种Primary数据库mongodb。


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

Smtp

type SmtpInfo struct {
	Host     string
	Password string
	Port     int
	Sender   string
	Subject  string
}

Notification的架构设计中支持多种提醒方式,如邮件,短信,REST Callback,MQTT Sender,AMQP Sender等等,但是目前已经实现的仅仅有两种: 邮件和rest callback,smtp就是邮件提醒的配置参数:

    Host     邮件服务器主机
    Password 密码
    Port     邮件服务器端口
    Sender   用户名
    Subject  邮件主题

猜你喜欢

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