Merge pull request #11024 from thalesmg/pulsar-cosmetic-connecting-check-r51
feat(pulsar): retry health check a bit before returning (r5.1)
This commit is contained in:
commit
c11011d857
|
@ -64,6 +64,8 @@
|
||||||
-define(pulsar_client_id, pulsar_client_id).
|
-define(pulsar_client_id, pulsar_client_id).
|
||||||
-define(pulsar_producers, pulsar_producers).
|
-define(pulsar_producers, pulsar_producers).
|
||||||
|
|
||||||
|
-define(HEALTH_CHECK_RETRY_TIMEOUT, 4_000).
|
||||||
|
|
||||||
%%-------------------------------------------------------------------------------------
|
%%-------------------------------------------------------------------------------------
|
||||||
%% `emqx_resource' API
|
%% `emqx_resource' API
|
||||||
%%-------------------------------------------------------------------------------------
|
%%-------------------------------------------------------------------------------------
|
||||||
|
@ -440,9 +442,18 @@ render(Message, Template) ->
|
||||||
emqx_placeholder:proc_tmpl(Template, Message, Opts).
|
emqx_placeholder:proc_tmpl(Template, Message, Opts).
|
||||||
|
|
||||||
get_producer_status(Producers) ->
|
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
|
case pulsar_producers:all_connected(Producers) of
|
||||||
true -> connected;
|
true ->
|
||||||
false -> connecting
|
connected;
|
||||||
|
false ->
|
||||||
|
Sleep = 200,
|
||||||
|
timer:sleep(Sleep),
|
||||||
|
do_get_producer_status(Producers, TimeSpent + Sleep)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
partition_strategy(key_dispatch) -> first_key_dispatch;
|
partition_strategy(key_dispatch) -> first_key_dispatch;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Added a small improvement to reduce the chance of seeing the `connecting` state when creating/updating a Pulsar Producer bridge.
|
Loading…
Reference in New Issue