Method: NATS#schedule_primary_and_connect
- Defined in:
- lib/nats/client.rb
permalink #schedule_primary_and_connect ⇒ Object
We have failed on an attempt at the primary (first) server, rotate and try again
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
# File 'lib/nats/client.rb', line 1350 def schedule_primary_and_connect #:nodoc: # Dump the one we were trying if it wasn't connected current = server_pool.shift # In case there was an error from the server we will take it out from rotation # unless we specify infinite reconnects via setting :max_reconnect_attempts to -1 if current && ([:max_reconnect_attempts] < 0 || can_reuse_server?(current)) server_pool << current end # If we are out of options, go ahead and disconnect then # handle closing connection to NATS. process_disconnect and return if server_pool.empty? # bind new one next_server = bind_primary # If the next one was connected and we are trying to reconnect # set up timer if we tried once already. if should_delay_connect?(next_server) schedule_reconnect else attempt_reconnect schedule_primary_and_connect if had_error? end end |