Class: Journaled::KinesisBatchSender
- Inherits:
-
Object
- Object
- Journaled::KinesisBatchSender
- Defined in:
- lib/journaled/kinesis_batch_sender.rb
Overview
Sends batches of events to Kinesis using the PutRecord single-event API
This class handles:
-
Sending events individually to support guaranteed ordering
-
Handling failures on a per-event basis
-
Classifying errors as transient vs permanent
Returns structured results for the caller to handle event state management.
Defined Under Namespace
Classes: FailedEvent
Constant Summary collapse
- PERMANENT_ERROR_CLASSES =
[ Aws::Kinesis::Errors::ValidationException, ].freeze
Instance Method Summary collapse
-
#send_batch(events) ⇒ Hash
Send a batch of database events to Kinesis.
Instance Method Details
#send_batch(events) ⇒ Hash
Send a batch of database events to Kinesis
Sends events one at a time to guarantee ordering. Stops on first transient failure.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/journaled/kinesis_batch_sender.rb', line 35 def send_batch(events) result = { succeeded: [], failed: [] } events.each do |event| event_result = send_event(event) if event_result.is_a?(FailedEvent) if event_result.transient? emit_transient_failure_metric break else result[:failed] << event_result end else result[:succeeded] << event_result end end result end |