chore: cosmetic changes
This commit is contained in:
parent
7b2b2b527c
commit
7a09b0470d
|
@ -57,7 +57,9 @@
|
|||
-define(HEALTH_CHECK_TIMEOUT, 1000).
|
||||
-define(INGRESS, "I").
|
||||
-define(EGRESS, "E").
|
||||
-define(IS_NO_PREFIX(P), (P =:= undefined orelse P =:= <<>>)).
|
||||
-define(NO_PREFIX, <<>>).
|
||||
-define(IS_NO_PREFIX(P), (P =:= undefined orelse P =:= ?NO_PREFIX)).
|
||||
-define(MAX_PREFIX_BYTES, 19).
|
||||
|
||||
%% ===================================================================
|
||||
%% When use this bridge as a data source, ?MODULE:on_message_received will be called
|
||||
|
@ -444,7 +446,7 @@ clientid(Name, _Conf = #{clientid_prefix := Prefix}) when
|
|||
->
|
||||
{Prefix, emqx_bridge_mqtt_lib:clientid_base(Name)};
|
||||
clientid(Name, _Conf) ->
|
||||
{undefined, emqx_bridge_mqtt_lib:clientid_base(Name)}.
|
||||
{?NO_PREFIX, emqx_bridge_mqtt_lib:clientid_base(Name)}.
|
||||
|
||||
%% @doc Start an ingress bridge worker.
|
||||
-spec connect([option() | {ecpool_worker_id, pos_integer()}]) ->
|
||||
|
@ -485,10 +487,9 @@ mk_client_opts(
|
|||
mk_clientid(WorkerId, {Prefix, ClientId}) when ?IS_NO_PREFIX(Prefix) ->
|
||||
%% When there is no prefix, try to keep the client ID length within 23 bytes
|
||||
emqx_bridge_mqtt_lib:bytes23(ClientId, WorkerId);
|
||||
mk_clientid(WorkerId, {Prefix, ClientId}) when size(Prefix) < 20 ->
|
||||
%% Try to respect client ID prefix when it's less than 20 bytes
|
||||
%% meaning there is at least 3 bytes to randomize
|
||||
%% Must add $: for backward compatibility
|
||||
mk_clientid(WorkerId, {Prefix, ClientId}) when size(Prefix) =< ?MAX_PREFIX_BYTES ->
|
||||
%% Try to respect client ID prefix when it's no more than 19 bytes,
|
||||
%% meaning there are at least 4 bytes as hash space.
|
||||
emqx_bridge_mqtt_lib:bytes23_with_prefix(Prefix, ClientId, WorkerId);
|
||||
mk_clientid(WorkerId, {Prefix, ClientId}) ->
|
||||
%% There is no other option but to use a long client ID
|
||||
|
|
Loading…
Reference in New Issue