Class: CDC::Concurrent::ResultCollector
- Inherits:
-
Object
- Object
- CDC::Concurrent::ResultCollector
- Defined in:
- lib/cdc/concurrent/result_collector.rb
Overview
Normalizes values returned by Async tasks into ProcessorResult objects.
ResultCollector keeps runtime pools tolerant of processors that either return a CDC::Core::ProcessorResult directly or return a plain Ruby value. Plain values are wrapped as successful ProcessorResult instances, while raised errors are represented as failure results.
Class Method Summary collapse
-
.failure(error) ⇒ CDC::Core::ProcessorResult
Wraps an exception as a failed ProcessorResult.
-
.normalize(value) ⇒ CDC::Core::ProcessorResult
Normalizes a processor return value into a ProcessorResult.
Class Method Details
.failure(error) ⇒ CDC::Core::ProcessorResult
Wraps an exception as a failed ProcessorResult.
28 29 30 |
# File 'lib/cdc/concurrent/result_collector.rb', line 28 def self.failure(error) CDC::Core::ProcessorResult.failure(error) end |
.normalize(value) ⇒ CDC::Core::ProcessorResult
Normalizes a processor return value into a ProcessorResult.
16 17 18 19 20 21 22 |
# File 'lib/cdc/concurrent/result_collector.rb', line 16 def self.normalize(value) return value if value.is_a?(CDC::Core::ProcessorResult) CDC::Core::ProcessorResult.success(value) rescue StandardError => e failure(e) end |