Class: JetstreamBridge::BatchPublisher::BatchResult
- Inherits:
-
Object
- Object
- JetstreamBridge::BatchPublisher::BatchResult
- Defined in:
- lib/jetstream_bridge/publisher/batch_publisher.rb
Overview
Result object for batch operations.
Contains aggregated results from a batch publish operation, including success/failure counts and detailed error information.
Instance Attribute Summary collapse
-
#errors ⇒ Array<Hash>
readonly
Array of error details with event_id and error.
-
#failed_count ⇒ Integer
readonly
Number of failed events.
-
#results ⇒ Array<Models::PublishResult>
readonly
All individual publish results.
-
#successful_count ⇒ Integer
readonly
Number of successfully published events.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Check if any events failed to publish.
-
#initialize(results) ⇒ BatchResult
constructor
private
A new instance of BatchResult.
-
#partial_success? ⇒ Boolean
Check if some (but not all) events published successfully.
-
#success? ⇒ Boolean
Check if all events published successfully.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(results) ⇒ BatchResult
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BatchResult.
58 59 60 61 62 63 64 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 58 def initialize(results) @results = results @successful_count = results.count(&:success?) @failed_count = results.count(&:failure?) @errors = results.select(&:failure?).map { |r| { event_id: r.event_id, error: r.error } } freeze end |
Instance Attribute Details
#errors ⇒ Array<Hash> (readonly)
Returns Array of error details with event_id and error.
54 55 56 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 54 def errors @errors end |
#failed_count ⇒ Integer (readonly)
Returns Number of failed events.
52 53 54 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 52 def failed_count @failed_count end |
#results ⇒ Array<Models::PublishResult> (readonly)
Returns All individual publish results.
48 49 50 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 48 def results @results end |
#successful_count ⇒ Integer (readonly)
Returns Number of successfully published events.
50 51 52 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 50 def successful_count @successful_count end |
Instance Method Details
#failure? ⇒ Boolean
Check if any events failed to publish.
76 77 78 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 76 def failure? !success? end |
#partial_success? ⇒ Boolean
Check if some (but not all) events published successfully.
83 84 85 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 83 def partial_success? @successful_count.positive? && @failed_count.positive? end |
#success? ⇒ Boolean
Check if all events published successfully.
69 70 71 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 69 def success? @failed_count.zero? end |
#to_h ⇒ Object Also known as: to_hash
87 88 89 90 91 92 93 94 |
# File 'lib/jetstream_bridge/publisher/batch_publisher.rb', line 87 def to_h { successful_count: @successful_count, failed_count: @failed_count, total_count: @results.size, errors: @errors } end |