Class: ElasticGraph::Indexer::FailedEventError
- Inherits:
-
Error
- Object
- Error
- ElasticGraph::Indexer::FailedEventError
- Defined in:
- lib/elastic_graph/indexer/failed_event_error.rb
Overview
Indicates an event that we attempted to process which failed for some reason. It may have failed due to a validation issue before we even attempted to write it to the datastore, or it could have failed in the datastore itself.
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
The invalid event.
-
#main_message ⇒ Object
readonly
The “main” part of the error message (without the ‘full_id` portion).
-
#operations ⇒ Object
readonly
The operations that would have been returned by the ‘OperationFactory` if the event was valid.
Class Method Summary collapse
Instance Method Summary collapse
- #full_id ⇒ Object
- #id ⇒ Object
-
#initialize(event:, operations:, main_message:) ⇒ FailedEventError
constructor
A new instance of FailedEventError.
- #op ⇒ Object
- #record ⇒ Object
- #type ⇒ Object
- #version ⇒ Object
-
#versioned_operations ⇒ Object
A filtered list of operations that have versions that can be compared against our event version.
Constructor Details
#initialize(event:, operations:, main_message:) ⇒ FailedEventError
Returns a new instance of FailedEventError.
39 40 41 42 43 44 45 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 39 def initialize(event:, operations:, main_message:) @main_message = @event = event @operations = operations super("#{full_id}: #{}") end |
Instance Attribute Details
#event ⇒ Object (readonly)
The invalid event.
24 25 26 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 24 def event @event end |
#main_message ⇒ Object (readonly)
The “main” part of the error message (without the ‘full_id` portion).
21 22 23 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 21 def @main_message end |
#operations ⇒ Object (readonly)
The operations that would have been returned by the ‘OperationFactory` if the event was valid. Note that sometimes an event is so malformed that we can’t build any operations for it, but most of the time we can.
29 30 31 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 29 def operations @operations end |
Class Method Details
.from_failed_operation_result(result, all_operations_for_event) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 31 def self.from_failed_operation_result(result, all_operations_for_event) new( event: result.event, operations: all_operations_for_event, main_message: result.summary ) end |
Instance Method Details
#full_id ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 53 def full_id event_id = EventID.from_event(event).to_s if ( = event["message_id"]) "#{event_id} (message_id: #{})" else event_id end end |
#id ⇒ Object
62 63 64 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 62 def id event["id"] end |
#op ⇒ Object
66 67 68 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 66 def op event["op"] end |
#record ⇒ Object
78 79 80 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 78 def record event["record"] end |
#type ⇒ Object
70 71 72 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 70 def type event["type"] end |
#version ⇒ Object
74 75 76 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 74 def version event["version"] end |
#versioned_operations ⇒ Object
A filtered list of operations that have versions that can be compared against our event version. Not all operation types have a version (e.g. derived indexing ‘Update` operations don’t).
49 50 51 |
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 49 def versioned_operations @versioned_operations ||= operations.select(&:versioned?) end |