Skip to content

Commit

Permalink
Merge pull request #11024 from thalesmg/pulsar-cosmetic-connecting-ch…
Browse files Browse the repository at this point in the history
…eck-r51

feat(pulsar): retry health check a bit before returning (r5.1)
  • Loading branch information
thalesmg committed Jun 12, 2023
2 parents 0bd6278 + db5d14d commit c11011d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions apps/emqx_bridge_pulsar/src/emqx_bridge_pulsar_impl_producer.erl
Expand Up @@ -64,6 +64,8 @@
-define(pulsar_client_id, pulsar_client_id).
-define(pulsar_producers, pulsar_producers).

-define(HEALTH_CHECK_RETRY_TIMEOUT, 4_000).

%%-------------------------------------------------------------------------------------
%% `emqx_resource' API
%%-------------------------------------------------------------------------------------
Expand Down Expand Up @@ -440,9 +442,18 @@ render(Message, Template) ->
emqx_placeholder:proc_tmpl(Template, Message, Opts).

get_producer_status(Producers) ->
do_get_producer_status(Producers, 0).

do_get_producer_status(_Producers, TimeSpent) when TimeSpent > ?HEALTH_CHECK_RETRY_TIMEOUT ->
connecting;
do_get_producer_status(Producers, TimeSpent) ->
case pulsar_producers:all_connected(Producers) of
true -> connected;
false -> connecting
true ->
connected;
false ->
Sleep = 200,
timer:sleep(Sleep),
do_get_producer_status(Producers, TimeSpent + Sleep)
end.

partition_strategy(key_dispatch) -> first_key_dispatch;
Expand Down
1 change: 1 addition & 0 deletions changes/ee/feat-11024.en.md
@@ -0,0 +1 @@
Added a small improvement to reduce the chance of seeing the `connecting` state when creating/updating a Pulsar Producer bridge.

0 comments on commit c11011d

Please sign in to comment.