Class: DistribCore::Leader::RetryOnDifferentErrorHandler

Inherits:
ErrorHandler
  • Object
show all
Defined in:
lib/distrib_core/leader/retry_on_different_error_handler.rb

Overview

Only retry if the error is different.

Instance Attribute Summary

Attributes inherited from ErrorHandler

#failed_workers_count, #failed_workers_threshold, #fatal_worker_failures, #retry_attempts, #retryable_exceptions

Instance Method Summary collapse

Methods inherited from ErrorHandler

#ignore_worker_failure?

Constructor Details

#initialize(exception_extractor, retry_limit: 2, repeated_error_limit: 1) ⇒ RetryOnDifferentErrorHandler

Returns a new instance of RetryOnDifferentErrorHandler.



5
6
7
8
9
10
# File 'lib/distrib_core/leader/retry_on_different_error_handler.rb', line 5

def initialize(exception_extractor, retry_limit: 2, repeated_error_limit: 1)
  super(exception_extractor)
  @exceptions_per_test = Hash.new([])
  @retry_limit = retry_limit
  @repeated_error_limit = repeated_error_limit
end

Instance Method Details

#retry_test?(test, results, exception) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/distrib_core/leader/retry_on_different_error_handler.rb', line 12

def retry_test?(test, results, exception)
  return false if retries_per_test[test] >= retry_limit

  failures_causes = aggregate_failure_causes(exception, results)

  return false if failures_causes.empty? || repeated_error_limit_exceeded?(test, failures_causes)

  exceptions_per_test[test] += failures_causes
  retries_per_test[test] += 1

  true
end