Class: Pgbus::Process::Dispatcher::LoopOutcome
- Inherits:
-
Object
- Object
- Pgbus::Process::Dispatcher::LoopOutcome
- Defined in:
- lib/pgbus/process/dispatcher.rb
Overview
Accumulates the per-item outcomes of a task that loops over queues. A task should only be considered failed when it attempted work and every attempt failed — a partial failure (some items succeed) must not trip maintenance backoff. #result returns the first error in the total-failure case and nil otherwise, matching the "return e on failure" contract run_if_due expects.
Instance Method Summary collapse
-
#initialize ⇒ LoopOutcome
constructor
A new instance of LoopOutcome.
- #record_failure(error) ⇒ Object
- #record_success ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize ⇒ LoopOutcome
Returns a new instance of LoopOutcome.
75 76 77 78 79 |
# File 'lib/pgbus/process/dispatcher.rb', line 75 def initialize @successes = 0 @failures = 0 @first_error = nil end |
Instance Method Details
#record_failure(error) ⇒ Object
85 86 87 88 |
# File 'lib/pgbus/process/dispatcher.rb', line 85 def record_failure(error) @failures += 1 @first_error = error if @first_error.nil? end |
#record_success ⇒ Object
81 82 83 |
# File 'lib/pgbus/process/dispatcher.rb', line 81 def record_success @successes += 1 end |
#result ⇒ Object
90 91 92 |
# File 'lib/pgbus/process/dispatcher.rb', line 90 def result @first_error if @failures.positive? && @successes.zero? end |