From e26e7acaa1f542ab79ad755e8bc9c6432cf2cee7 Mon Sep 17 00:00:00 2001 From: Serge Tupchii Date: Thu, 23 May 2024 12:32:46 +0300 Subject: [PATCH] refactor(clusterlink): use `emqx_bridge_mqtt_lib:clientid_base/1` to construct routesync client id --- .../src/emqx_cluster_link_router_syncer.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/emqx_cluster_link/src/emqx_cluster_link_router_syncer.erl b/apps/emqx_cluster_link/src/emqx_cluster_link_router_syncer.erl index 62d434071..2a19a54b3 100644 --- a/apps/emqx_cluster_link/src/emqx_cluster_link_router_syncer.erl +++ b/apps/emqx_cluster_link/src/emqx_cluster_link_router_syncer.erl @@ -51,6 +51,9 @@ -define(RECONNECT_TIMEOUT, 5_000). +-define(CLIENT_SUFFIX, ":routesync"). +-define(PS_CLIENT_SUFFIX, ":routesync-ps"). + %% Special actor for persistent routes that has the same actor name on all nodes. %% Node actors with the same name nay race with each other (e.g. during bootstrap), %% but it must be tolerable, since persistent route destination is a client ID, @@ -132,12 +135,12 @@ start_link_client(TargetCluster, Actor) -> refine_client_options(Options = #{clientid := ClientID}, Actor) -> Suffix = case Actor of - ?PS_ACTOR -> "-ps"; - _ -> "" + ?PS_ACTOR -> ?PS_CLIENT_SUFFIX; + _ -> ?CLIENT_SUFFIX end, %% TODO: Reconnect should help, but it looks broken right now. Options#{ - clientid => emqx_utils:format("~s:~s:routesync~s", [ClientID, node(), Suffix]), + clientid => emqx_bridge_mqtt_lib:clientid_base([ClientID, Suffix]), clean_start => false, properties => #{'Session-Expiry-Interval' => 60}, retry_interval => 0