From d9a98b94a353b068ccc2f88cd63a48f5a80fe9a2 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Thu, 21 Feb 2019 13:41:14 +0800 Subject: [PATCH] Fix app config generation (#2245) --- etc/emqx.conf | 260 +++++++++++++++++++------------------ priv/emqx.schema | 8 +- test/emqx_portal_SUITE.erl | 1 - 3 files changed, 140 insertions(+), 129 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index 78ec499b64..f1a3a111f8 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -1591,34 +1591,12 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ##-------------------------------------------------------------------- ## Bridges to aws ##-------------------------------------------------------------------- -## Start type of the bridge. -## -## Value: enum -## manual -## auto -## bridge.aws.start_type = manual - -## Bridge reconnect time. -## -## Value: Duration -## Default: 30 seconds -## bridge.aws.reconnect_interval = 30s - -## Retry interval for bridge QoS1 message delivering. -## -## Value: Duration -## bridge.aws.retry_interval = 20s - -## Inflight size. -## -## Value: Integer -## bridge.aws.max_inflight = 32 ## Bridge address: node name for local bridge, host:port for remote. ## ## Value: String ## Example: emqx@127.0.0.1, 127.0.0.1:1883 -## bridge.aws.address = 127.0.0.1:1883 +bridge.aws.address = 127.0.0.1:1883 ## Protocol version of the bridge. ## @@ -1626,12 +1604,12 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## - mqttv5 ## - mqttv4 ## - mqttv3 -## bridge.aws.proto_ver = mqttv4 +bridge.aws.proto_ver = mqttv4 ## The ClientId of a remote bridge. ## ## Value: String -## bridge.aws.client_id = bridge_aws +bridge.aws.client_id = bridge_aws ## The Clean start flag of a remote bridge. ## @@ -1640,54 +1618,107 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## ## NOTE: Some IoT platforms require clean_start ## must be set to 'true' -## bridge.aws.clean_start = true +bridge.aws.clean_start = true ## The username for a remote bridge. ## ## Value: String -## bridge.aws.username = user +bridge.aws.username = user ## The password for a remote bridge. ## ## Value: String -## bridge.aws.password = passwd +bridge.aws.password = passwd ## Mountpoint of the bridge. ## ## Value: String -## bridge.aws.mountpoint = bridge/aws/${node}/ +bridge.aws.mountpoint = bridge/aws/${node}/ + +## Forward message topics +## +## Value: String +## Example: topic1/#,topic2/# +bridge.aws.forwards = topic1/#,topic2/# + +## Bribge to remote server via SSL. +## +## Value: on | off +bridge.aws.ssl = off + +## PEM-encoded CA certificates of the bridge. +## +## Value: File +bridge.aws.cacertfile = {{ platform_etc_dir }}/certs/cacert.pem + +## Client SSL Certfile of the bridge. +## +## Value: File +bridge.aws.certfile = {{ platform_etc_dir }}/certs/client-cert.pem + +## Client SSL Keyfile of the bridge. +## +## Value: File +bridge.aws.keyfile = {{ platform_etc_dir }}/certs/client-key.pem + +## SSL Ciphers used by the bridge. +## +## Value: String +bridge.aws.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384 ## Ping interval of a down bridge. ## ## Value: Duration ## Default: 10 seconds -## bridge.aws.keepalive = 60s +bridge.aws.keepalive = 60s -## Forward message topics +## TLS versions used by the bridge. ## ## Value: String -## Example: topic1/#,topic2/# -## bridge.aws.forwards = topic1/#,topic2/# +bridge.aws.tls_versions = tlsv1.2,tlsv1.1,tlsv1 ## Subscriptions of the bridge topic. ## ## Value: String -## bridge.aws.subscription.1.topic = cmd/topic1 +bridge.aws.subscription.1.topic = cmd/topic1 ## Subscriptions of the bridge qos. ## ## Value: Number -## bridge.aws.subscription.1.qos = 1 +bridge.aws.subscription.1.qos = 1 ## Subscriptions of the bridge topic. ## ## Value: String -## bridge.aws.subscription.2.topic = cmd/topic2 +bridge.aws.subscription.2.topic = cmd/topic2 ## Subscriptions of the bridge qos. ## ## Value: Number -## bridge.aws.subscription.2.qos = 1 +bridge.aws.subscription.2.qos = 1 + +## Start type of the bridge. +## +## Value: enum +## manual +## auto +bridge.aws.start_type = manual + +## Bridge reconnect time. +## +## Value: Duration +## Default: 30 seconds +bridge.aws.reconnect_interval = 30s + +## Retry interval for bridge QoS1 message delivering. +## +## Value: Duration +bridge.aws.retry_interval = 20s + +## Inflight size. +## +## Value: Integer +bridge.aws.max_inflight = 32 ## Maximum number of messages in one batch when sending to remote borkers ## NOTE: when bridging via MQTT connection to remote broker, this config is only @@ -1696,76 +1727,23 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## ## Value: Integer ## default: 32 -## bridge.aws.queue.batch_size = 32 +bridge.aws.queue.batch_size = 32 ## Base directory for replayq to store messages on disk ## If this config entry is missing or set to undefined, ## replayq works in a mem-only manner. ## ## Value: String -## bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/ +bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/ ## Replayq segment size ## ## Value: Bytesize - -## bridge.aws.queue.replayq_seg_bytes = 10MB - -## Bribge to remote server via SSL. -## -## Value: on | off -## bridge.aws.ssl = off - -## PEM-encoded CA certificates of the bridge. -## -## Value: File -## bridge.aws.cacertfile = {{ platform_etc_dir }}/certs/cacert.pem - -## Client SSL Certfile of the bridge. -## -## Value: File -## bridge.aws.certfile = {{ platform_etc_dir }}/certs/client-cert.pem - -## Client SSL Keyfile of the bridge. -## -## Value: File -## bridge.aws.keyfile = {{ platform_etc_dir }}/certs/client-key.pem - -## SSL Ciphers used by the bridge. -## -## Value: String -## bridge.aws.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384 - -## TLS versions used by the bridge. -## -## Value: String -## bridge.aws.tls_versions = tlsv1.2,tlsv1.1,tlsv1 +bridge.aws.queue.replayq_seg_bytes = 10MB ##-------------------------------------------------------------------- ## Bridges to azure ##-------------------------------------------------------------------- -## Start type of the bridge. -## -## Value: enum -## manual -## auto -## bridge.azure.start_type = manual - -## Bridge reconnect count. -## -## Value: Number -## bridge.azure.reconnect_count = 10 - -## Bridge reconnect time. -## -## Value: Duration -## Default: 30 seconds -## bridge.azure.reconnect_time = 30s - -## Retry interval for bridge QoS1 message delivering. -## -## Value: Duration -## bridge.azure.retry_interval = 20s ## Bridge address: node name for local bridge, host:port for remote. ## @@ -1784,7 +1762,7 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## The ClientId of a remote bridge. ## ## Value: String -## bridge.azure.client_id = bridge_azure +## bridge.azure.client_id = bridge_aws ## The Clean start flag of a remote bridge. ## @@ -1808,24 +1786,54 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## Mountpoint of the bridge. ## ## Value: String -## bridge.azure.mountpoint = bridge/azure/${node}/ +## bridge.azure.mountpoint = bridge/aws/${node}/ + +## Forward message topics +## +## Value: String +## Example: topic1/#,topic2/# +## bridge.azure.forwards = topic1/#,topic2/# + +## Bribge to remote server via SSL. +## +## Value: on | off +## bridge.azure.ssl = off + +## PEM-encoded CA certificates of the bridge. +## +## Value: File +## bridge.azure.cacertfile = {{ platform_etc_dir }}/certs/cacert.pem + +## Client SSL Certfile of the bridge. +## +## Value: File +## bridge.azure.certfile = {{ platform_etc_dir }}/certs/client-cert.pem + +## Client SSL Keyfile of the bridge. +## +## Value: File +## bridge.azure.keyfile = {{ platform_etc_dir }}/certs/client-key.pem + +## SSL Ciphers used by the bridge. +## +## Value: String +## bridge.azure.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384 ## Ping interval of a down bridge. ## ## Value: Duration ## Default: 10 seconds -## bridge.azure.keepalive = 10s +## bridge.azure.keepalive = 60s -## Forward message topics +## TLS versions used by the bridge. ## ## Value: String -## Example: topic1/#,topic2/# -## bridge.azure.forwards = topic1/#,topic2/# +## bridge.azure.tls_versions = tlsv1.2,tlsv1.1,tlsv1 ## Subscriptions of the bridge topic. ## ## Value: String -## bridge.azure.subscription.1.topic = $share/cmd/topic1 +## bridge.azure.subscription.1.topic = cmd/topic1 ## Subscriptions of the bridge qos. ## @@ -1835,13 +1843,36 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## Subscriptions of the bridge topic. ## ## Value: String -## bridge.azure.subscription.2.topic = $share/cmd/topic2 +## bridge.azure.subscription.2.topic = cmd/topic2 ## Subscriptions of the bridge qos. ## ## Value: Number ## bridge.azure.subscription.2.qos = 1 +## Start type of the bridge. +## +## Value: enum +## manual +## auto +## bridge.azure.start_type = manual + +## Bridge reconnect time. +## +## Value: Duration +## Default: 30 seconds +## bridge.azure.reconnect_interval = 30s + +## Retry interval for bridge QoS1 message delivering. +## +## Value: Duration +## bridge.azure.retry_interval = 20s + +## Inflight size. +## +## Value: Integer +## bridge.azure.max_inflight = 32 + ## Maximum number of messages in one batch when sending to remote borkers ## NOTE: when bridging via MQTT connection to remote broker, this config is only ## used for internal message passing optimization as the underlying MQTT @@ -1856,38 +1887,13 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G ## replayq works in a mem-only manner. ## ## Value: String -## Default: "" -## bridge.azure.queue.replayq_dir = {{ platform_data_dir }}/emqx_azure.bridge/ +## bridge.azure.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/ ## Replayq segment size ## ## Value: Bytesize ## bridge.azure.queue.replayq_seg_bytes = 10MB -## PEM-encoded CA certificates of the bridge. -## -## Value: File -## bridge.azure.cacertfile = cacert.pem - -## Client SSL Certfile of the bridge. -## -## Value: File -## bridge.azure.certfile = cert.pem - -## Client SSL Keyfile of the bridge. -## -## Value: File -## bridge.azure.keyfile = key.pem - -## SSL Ciphers used by the bridge. -## -## Value: String -## bridge.azure.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384 - -## TLS versions used by the bridge. -## -## Value: String -## bridge.azure.tls_versions = tlsv1.2,tlsv1.1,tlsv1 ##-------------------------------------------------------------------- ## Modules diff --git a/priv/emqx.schema b/priv/emqx.schema index 62cba9af91..3a0f19bb38 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -1591,6 +1591,11 @@ end}. {datatype, {duration, ms}} ]}. +{mapping, "bridge.$name.retry_interval", "emqx.bridges", [ + {default, "20s"}, + {datatype, {duration, ms}} +]}. + {mapping, "bridge.$name.max_inflight", "emqx.bridges", [ {default, 0}, {datatype, integer} @@ -1655,7 +1660,8 @@ end}. end end, ConnMod = fun(Name) -> - [Addr] = cuttlefish_variable:filter_by_prefix("bridge." ++ Name ++ ".address", Conf), + [AddrConfig] = cuttlefish_variable:filter_by_prefix("bridge." ++ Name ++ ".address", Conf), + {_, Addr} = AddrConfig, Subs = Subscriptions(Name), case IsNodeAddr(Addr) of true when Subs =/= [] -> diff --git a/test/emqx_portal_SUITE.erl b/test/emqx_portal_SUITE.erl index 3c380d6846..8b80fb72f9 100644 --- a/test/emqx_portal_SUITE.erl +++ b/test/emqx_portal_SUITE.erl @@ -190,4 +190,3 @@ do_receive_and_match_messages(Ref, [I | Rest]) -> end, do_receive_and_match_messages(Ref, Rest) end. -