Class: ElasticGraph::Indexer::FailedEventError

Inherits:
Error
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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 = main_message
  @event = event
  @operations = operations

  super("#{full_id}: #{main_message}")
end

Instance Attribute Details

#eventObject (readonly)

The invalid event.



24
25
26
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 24

def event
  @event
end

#main_messageObject (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
  @main_message
end

#operationsObject (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_idObject



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 (message_id = event["message_id"])
    "#{event_id} (message_id: #{message_id})"
  else
    event_id
  end
end

#idObject



62
63
64
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 62

def id
  event["id"]
end

#opObject



66
67
68
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 66

def op
  event["op"]
end

#recordObject



78
79
80
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 78

def record
  event["record"]
end

#typeObject



70
71
72
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 70

def type
  event["type"]
end

#versionObject



74
75
76
# File 'lib/elastic_graph/indexer/failed_event_error.rb', line 74

def version
  event["version"]
end

#versioned_operationsObject

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