优化结构
This commit is contained in:
@@ -233,6 +233,9 @@ func validateCommunicationIntegrationConfig(kind, provider string, values map[st
|
||||
if timeout := integrationInt64(values, "connect_timeout", 0); timeout <= 0 {
|
||||
return errors.New("emqx connect_timeout 必须大于 0")
|
||||
}
|
||||
if interval := integrationInt64(values, "reconnect_interval", 0); interval <= 0 {
|
||||
return errors.New("emqx reconnect_interval 必须大于 0")
|
||||
}
|
||||
case IntegrationKindMQ + "/rabbitmq":
|
||||
port := integrationInt64(values, "port", 0)
|
||||
if port < 1 || port > 65535 {
|
||||
@@ -251,6 +254,9 @@ func validateCommunicationIntegrationConfig(kind, provider string, values map[st
|
||||
if integrationInt64(values, "connect_timeout", 0) <= 0 {
|
||||
return errors.New("rabbitmq connect_timeout 必须大于 0")
|
||||
}
|
||||
if integrationInt64(values, "reconnect_interval", 0) <= 0 {
|
||||
return errors.New("rabbitmq reconnect_interval 必须大于 0")
|
||||
}
|
||||
case IntegrationKindWebSocket + "/melody":
|
||||
path := integrationText(values, "path")
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
|
||||
@@ -92,7 +92,7 @@ var integrationDefinitions = map[string][]IntegrationConfigDefinition{
|
||||
IntegrationKindMQ: {
|
||||
{
|
||||
Kind: IntegrationKindMQ, Provider: "emqx", Name: "EMQX", Description: "EMQX MQTT 消息服务",
|
||||
Defaults: map[string]any{"broker": "tcp://127.0.0.1:1883", "client_id": "kra", "username": "", "password": "", "keep_alive": 30, "clean_session": true, "connect_timeout": 10},
|
||||
Defaults: map[string]any{"broker": "tcp://127.0.0.1:1883", "client_id": "kra", "username": "", "password": "", "keep_alive": 30, "clean_session": true, "connect_timeout": 10, "reconnect_interval": 5},
|
||||
Fields: []IntegrationConfigField{
|
||||
{Key: "broker", Label: "Broker 地址", Type: "text", Required: true, Placeholder: "tcp://127.0.0.1:1883"},
|
||||
{Key: "client_id", Label: "客户端 ID", Type: "text", Required: true, Placeholder: "kra"},
|
||||
@@ -101,11 +101,12 @@ var integrationDefinitions = map[string][]IntegrationConfigDefinition{
|
||||
{Key: "keep_alive", Label: "心跳间隔(秒)", Type: "number", Required: true},
|
||||
{Key: "clean_session", Label: "清理会话", Type: "switch", Description: "连接时不恢复 Broker 端保存的旧会话。"},
|
||||
{Key: "connect_timeout", Label: "连接超时(秒)", Type: "number", Required: true},
|
||||
{Key: "reconnect_interval", Label: "重连退避上限(秒)", Type: "number", Required: true, Description: "网络中断后自动重连的最大退避间隔。"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Kind: IntegrationKindMQ, Provider: "rabbitmq", Name: "RabbitMQ", Description: "RabbitMQ AMQP 消息队列",
|
||||
Defaults: map[string]any{"host": "127.0.0.1", "port": 5672, "username": "guest", "password": "guest", "vhost": "/", "exchange": "kra", "exchange_type": "topic", "queue": "kra", "routing_key": "#", "durable": true, "auto_delete": false, "prefetch_count": 10, "heartbeat": 10, "connect_timeout": 10, "tls": false},
|
||||
Defaults: map[string]any{"host": "127.0.0.1", "port": 5672, "username": "guest", "password": "guest", "vhost": "/", "exchange": "kra", "exchange_type": "topic", "queue": "kra", "routing_key": "#", "durable": true, "auto_delete": false, "prefetch_count": 10, "heartbeat": 10, "connect_timeout": 10, "reconnect_interval": 5, "tls": false},
|
||||
Fields: []IntegrationConfigField{
|
||||
{Key: "host", Label: "主机", Type: "text", Required: true, Placeholder: "127.0.0.1"},
|
||||
{Key: "port", Label: "端口", Type: "number", Required: true},
|
||||
@@ -121,6 +122,7 @@ var integrationDefinitions = map[string][]IntegrationConfigDefinition{
|
||||
{Key: "prefetch_count", Label: "预取数量", Type: "number"},
|
||||
{Key: "heartbeat", Label: "心跳间隔(秒)", Type: "number"},
|
||||
{Key: "connect_timeout", Label: "连接超时(秒)", Type: "number", Required: true},
|
||||
{Key: "reconnect_interval", Label: "重连退避上限(秒)", Type: "number", Required: true, Description: "网络中断后自动重连的最大退避间隔。"},
|
||||
{Key: "tls", Label: "启用 TLS", Type: "switch"},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user