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.
      30 31 32  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 30 def initialize @errors = [] end  | 
  
Instance Method Details
#<<(error) ⇒ Object
      40 41 42 43  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 40 def <<(error) @errors.shift if @errors.size >= STORAGE_LIMIT @errors << error end  | 
  
#all ⇒ Array<StandardError>
Returns array with all the errors that occurred.
      67 68 69  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 67 def all @errors end  | 
  
#clear ⇒ Object
Clears all the errors
      35 36 37  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 35 def clear @errors.clear end  | 
  
#each(&block) ⇒ Object
Iterates over errors
      62 63 64  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 62 def each(&block) @errors.each(&block) end  | 
  
#empty? ⇒ Boolean
Returns is the error tracker empty.
      46 47 48  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 46 def empty? @errors.empty? end  | 
  
#last ⇒ StandardError?
Returns last error that occurred or nil if no errors.
      56 57 58  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 56 def last @errors.last end  | 
  
#size ⇒ Integer
Returns number of elements.
      51 52 53  | 
    
      # File 'lib/karafka/pro/processing/coordinators/errors_tracker.rb', line 51 def size count end  |