dataRT/config/rabbit.go

259 lines
5.0 KiB
Go

package config
type xqr struct {
ExchangeName string `json:"exchangename" yaml:"exchangename"`
QueueName string `json:"queuename" yaml:"queuename"`
RoutingKey string `json:"routingkey" yaml:"routingkey"`
QueueLength int64 `json:"queuelength" yaml:"queuelength"`
}
type tlsConfig struct {
CAPath string `json:"capath" yaml:"capath"`
KeyPath string `json:"keypath" yaml:"keypath"`
CertPath string `json:"certpath" yaml:"certpath"`
Password string `json:"password" yaml:"password"`
SkipVerify bool `json:"skipverify" yaml:"skipverify"`
ServerName string `json:"servername" yaml:"servername"`
}
type rabbitConfig struct {
Hosts []string `json:"hosts" yaml:"hosts"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
NXQR *xqr `json:"nxqr" yaml:"nxqr"`
DXQR *xqr `json:"dxqr" yaml:"dxqr"`
TLS *tlsConfig `json:"tls" yaml:"tls"`
}
func NewRabbitConfig() *rabbitConfig {
return new(rabbitConfig)
}
func (conf *rabbitConfig) GetHosts() []string {
if conf == nil {
panic("rabbit config is nil")
}
return conf.Hosts
}
func (conf *rabbitConfig) SetHosts(hosts []string) {
if conf == nil {
panic("rabbit config is nil")
}
conf.Hosts = hosts
}
func (conf *rabbitConfig) GetUsername() string {
if conf == nil {
panic("rabbit config is nil")
}
return conf.Username
}
func (conf *rabbitConfig) SetUsername(username string) {
if conf == nil {
panic("rabbit config is nil")
}
conf.Username = username
}
func (conf *rabbitConfig) GetPassword() string {
if conf == nil {
panic("rabbit config is nil")
}
return conf.Password
}
func (conf *rabbitConfig) SetPassword(password string) {
if conf == nil {
panic("rabbit config is nil")
}
conf.Password = password
}
func (conf *rabbitConfig) InitNXQR() {
if conf == nil {
panic("rabbit config is nil")
}
conf.NXQR = new(xqr)
}
func (conf *rabbitConfig) GetNXQR() *xqr {
if conf == nil {
panic("rabbit config is nil")
}
return conf.NXQR
}
func (conf *rabbitConfig) InitDXQR() {
if conf == nil {
panic("rabbit config is nil")
}
conf.DXQR = new(xqr)
}
func (conf *rabbitConfig) GetDXQR() *xqr {
if conf == nil {
panic("rabbit config is nil")
}
return conf.DXQR
}
func (conf *xqr) GetExchangeName() string {
if conf == nil {
panic("rabbit xqr is nil")
}
return conf.ExchangeName
}
func (conf *xqr) SetExchangeName(exchangeName string) {
if conf == nil {
panic("rabbit xqr is nil")
}
conf.ExchangeName = exchangeName
}
func (conf *xqr) GetQueueName() string {
if conf == nil {
panic("rabbit xqr is nil")
}
return conf.QueueName
}
func (conf *xqr) SetQueueName(queueName string) {
if conf == nil {
panic("rabbit xqr is nil")
}
conf.QueueName = queueName
}
func (conf *xqr) GetRoutingKey() string {
if conf == nil {
panic("rabbit xqr is nil")
}
return conf.RoutingKey
}
func (conf *xqr) SetRoutingKey(routingKey string) {
if conf == nil {
panic("rabbit xqr is nil")
}
conf.RoutingKey = routingKey
}
func (conf *xqr) GetQueueLength() int64 {
if conf == nil {
panic("rabbit xqr is nil")
}
return conf.QueueLength
}
func (conf *xqr) SetQueueLength(queueLength int64) {
if conf == nil {
panic("rabbit xqr is nil")
}
conf.QueueLength = queueLength
}
func (conf *rabbitConfig) InitTLS() {
if conf == nil {
panic("rabbit config is nil")
}
conf.TLS = new(tlsConfig)
}
func (conf *rabbitConfig) GetTLS() *tlsConfig {
if conf == nil {
panic("rabbit config is nil")
}
return conf.TLS
}
func (conf *tlsConfig) GetCAPath() string {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.CAPath
}
func (conf *tlsConfig) SetCAPath(caPath string) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.CAPath = caPath
}
func (conf *tlsConfig) GetKeyPath() string {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.KeyPath
}
func (conf *tlsConfig) SetKeyPath(keyPath string) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.KeyPath = keyPath
}
func (conf *tlsConfig) GetCertPath() string {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.CertPath
}
func (conf *tlsConfig) SetCertPath(certPath string) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.CertPath = certPath
}
func (conf *tlsConfig) GetPassword() string {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.Password
}
func (conf *tlsConfig) SetPassword(password string) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.Password = password
}
func (conf *tlsConfig) GetSkipVerify() bool {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.SkipVerify
}
func (conf *tlsConfig) SetSkipVerify(skipVerify bool) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.SkipVerify = skipVerify
}
func (conf *tlsConfig) GetServerName() string {
if conf == nil {
panic("rabbit tls is nil")
}
return conf.ServerName
}
func (conf *tlsConfig) SetServerName(serverName string) {
if conf == nil {
panic("rabbit tls is nil")
}
conf.ServerName = serverName
}
func rabbitConfigName() string {
return "rabbit.json"
}