From 13a35cc0455ca3f243ed98c3a11c6075bd385306 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Tue, 14 Mar 2023 12:17:08 +0100 Subject: [PATCH] fix: schema default value so that it shows up correctly in UI This complements PR https://github.com/emqx/emqx/pull/10124. The default values for duration_ms() fields needs to be formatted as a binary string with unit to show up correctly in the dashboard UI. --- apps/emqx_connector/src/emqx_connector_mongo.erl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/emqx_connector/src/emqx_connector_mongo.erl b/apps/emqx_connector/src/emqx_connector_mongo.erl index 8804ebaf2..ead3e2e49 100644 --- a/apps/emqx_connector/src/emqx_connector_mongo.erl +++ b/apps/emqx_connector/src/emqx_connector_mongo.erl @@ -106,7 +106,14 @@ fields(topology) -> {socket_timeout_ms, duration("socket_timeout")}, {server_selection_timeout_ms, duration("server_selection_timeout")}, {wait_queue_timeout_ms, duration("wait_queue_timeout")}, - {heartbeat_frequency_ms, fun heartbeat_frequency_ms/1}, + {heartbeat_frequency_ms, + hoconsc:mk( + emqx_schema:duration_ms(), + #{ + default => <<"200s">>, + desc => ?DESC("heartbeat_period") + } + )}, {min_heartbeat_frequency_ms, duration("min_heartbeat_period")} ]. @@ -407,12 +414,6 @@ duration(Desc) -> desc => ?DESC(Desc) }. -heartbeat_frequency_ms(type) -> emqx_schema:duration_ms(); -heartbeat_frequency_ms(desc) -> ?DESC("heartbeat_period"); -heartbeat_frequency_ms(default) -> 200000; -heartbeat_frequency_ms(validator) -> [?MIN(1)]; -heartbeat_frequency_ms(_) -> undefined. - max_overflow(type) -> non_neg_integer(); max_overflow(desc) -> ?DESC("max_overflow"); max_overflow(default) -> 0;