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
Initializes the result as successful with no cause.
-
#success! ⇒ Object
Marks state as successful.
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Result
Initializes the result as successful with no cause
12 13 14 15 |
# File 'lib/karafka/processing/result.rb', line 12 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
32 33 34 35 |
# File 'lib/karafka/processing/result.rb', line 32 def failure!(cause) @success = false @cause = cause end |
#failure? ⇒ Boolean
Returns true if processing failed.
38 39 40 |
# File 'lib/karafka/processing/result.rb', line 38 def failure? !@success end |
#success! ⇒ Object
Marks state as successful
23 24 25 26 27 28 |
# File 'lib/karafka/processing/result.rb', line 23 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
18 19 20 |
# File 'lib/karafka/processing/result.rb', line 18 def success? @success end |