@@ -92,8 +92,10 @@ flush_token(Gun, Headers) ->
92
92
init ({Name , Hosts , Options , Transport , TransportOpts }) ->
93
93
erlang :process_flag (trap_exit , true ),
94
94
GunOpts = #{protocols => [http2 ],
95
+ connect_timeout => proplists :get_value (connect_timeout , Options , 1000 ),
95
96
http2_opts => #{keepalive => 45000 },
96
- retry => 0 ,
97
+ retry => proplists :get_value (retry , Options , 0 ),
98
+ retry_timeout => proplists :get_value (retry_timeout , Options , 5000 ),
97
99
transport => Transport ,
98
100
transport_opts => TransportOpts
99
101
},
@@ -228,7 +230,11 @@ fold_connect([Host | Hosts], Name, GunOpts, Auth, Ok, Fail) ->
228
230
229
231
connect (Name , {IP , Port }, GunOpts , Auth ) ->
230
232
{ok , Gun } = gun :open (IP , Port , GunOpts ),
231
- case gun :await_up (Gun , 1000 ) of
233
+ Retries = maps :get (retry , GunOpts ),
234
+ ConnectTimeout = maps :get (connect_timeout , GunOpts ),
235
+ RetryTimeout = maps :get (retry_timeout , GunOpts ),
236
+ AwaitTime = (Retries + 1 ) * ConnectTimeout + Retries * RetryTimeout ,
237
+ case gun :await_up (Gun , AwaitTime ) of
232
238
{ok , http2 } ->
233
239
case check_health_remote (Gun ) of
234
240
ok ->
@@ -590,4 +596,3 @@ put_in_authenticate(Data, Options) ->
590
596
shuffle (List ) ->
591
597
Disorders = [begin {rand :uniform (), K } end ||K <- List ],
592
598
[begin K end ||{_ , K } <- lists :keysort (1 , Disorders )].
593
-
0 commit comments