Module: Itrp::SendWithRetries
- Defined in:
- lib/itrp/client.rb
Instance Method Summary collapse
-
#_send(request, domain = @domain, port = @port, ssl = @ssl) ⇒ Object
Wraps the _send method with retries when the server does not respond, see
initialize
option:retries
.
Instance Method Details
#_send(request, domain = @domain, port = @port, ssl = @ssl) ⇒ Object
Wraps the _send method with retries when the server does not respond, see initialize
option :retries
314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/itrp/client.rb', line 314 def _send(request, domain = @domain, port = @port, ssl = @ssl) retries = 0 sleep_time = 2 total_retry_time = 0 begin _response = super(request, domain, port, ssl) @logger.warn { "Request failed, retry ##{retries += 1} in #{sleep_time} seconds: #{_response.}" } and sleep(sleep_time) if (_response.raw.code.to_s != '204' && _response.empty?) && option(:max_retry_time) > 0 total_retry_time += sleep_time sleep_time *= 2 end while (_response.raw.code.to_s != '204' && _response.empty?) && total_retry_time < option(:max_retry_time) _response end |