Class: Karafka::Processing::Result
- Inherits:
-
Object
- Object
- Karafka::Processing::Result
- Defined in:
- lib/karafka/processing/result.rb
Overview
A simple object that allows us to keep track of processing state. It allows to indicate if given thing moved from success to a failure or the other way around Useful for tracking consumption state
Instance Attribute Summary collapse
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
Instance Method Summary collapse
-
#failure!(cause) ⇒ Object
Marks state as failure.
-
#failure? ⇒ Boolean
True if processing failed.
-
#initialize ⇒ Result
constructor
A new instance of Result.
-
#success! ⇒ Object
Marks state as successful.
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
11 12 13 14 |
# File 'lib/karafka/processing/result.rb', line 11 def initialize @success = true @cause = false end |
Instance Attribute Details
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
9 10 11 |
# File 'lib/karafka/processing/result.rb', line 9 def cause @cause end |
Instance Method Details
#failure!(cause) ⇒ Object
Marks state as failure
31 32 33 34 |
# File 'lib/karafka/processing/result.rb', line 31 def failure!(cause) @success = false @cause = cause end |
#failure? ⇒ Boolean
Returns true if processing failed.
37 38 39 |
# File 'lib/karafka/processing/result.rb', line 37 def failure? !@success end |
#success! ⇒ Object
Marks state as successful
22 23 24 25 26 27 |
# File 'lib/karafka/processing/result.rb', line 22 def success! @success = true # We set cause to false so the previous error that occurred does not leak when error is # no longer present @cause = false end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/karafka/processing/result.rb', line 17 def success? @success end |