Class: Karafka::Pro::Processing::Coordinators::ErrorsTracker
- Inherits:
-
Object
- Object
- Karafka::Pro::Processing::Coordinators::ErrorsTracker
- Includes:
- Enumerable
- Defined in:
- lib/karafka/pro/processing/coordinators/errors_tracker.rb
Overview
Object used to track errors in between executions to be able to build error-type based recovery flows.
Instance Method Summary collapse
- #<<(error) ⇒ Object
-
#all ⇒ Array<StandardError>
Array with all the errors that occurred.
-
#clear ⇒ Object
Clears all the errors.
-
#each(&block) ⇒ Object
Iterates over errors.
-
#empty? ⇒ Boolean
Is the error tracker empty.
-
#initialize ⇒ ErrorsTracker
constructor
A new instance of ErrorsTracker.
-
#last ⇒ StandardError?
Last error that occurred or nil if no errors.
-
#size ⇒ Integer
Number of elements.
Constructor Details
#initialize ⇒ ErrorsTracker
Returns a new instance of ErrorsTracker.
22 23 24 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 22 def initialize @errors = [] end |
Instance Method Details
#<<(error) ⇒ Object
32 33 34 35 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 32 def <<(error) @errors.shift if @errors.size >= STORAGE_LIMIT @errors << error end |
#all ⇒ Array<StandardError>
Returns array with all the errors that occurred.
59 60 61 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 59 def all @errors end |
#clear ⇒ Object
Clears all the errors
27 28 29 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 27 def clear @errors.clear end |
#each(&block) ⇒ Object
Iterates over errors
54 55 56 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 54 def each(&block) @errors.each(&block) end |
#empty? ⇒ Boolean
Returns is the error tracker empty.
38 39 40 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 38 def empty? @errors.empty? end |
#last ⇒ StandardError?
Returns last error that occurred or nil if no errors.
48 49 50 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 48 def last @errors.last end |
#size ⇒ Integer
Returns number of elements.
43 44 45 |
# File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 43 def size count end |