Class: PhobosDBCheckpoint::Failure

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
EventHelper
Defined in:
lib/phobos_db_checkpoint/failure.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EventHelper

#configured_handler, #configured_listener, #method_missing, #respond_to_missing?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PhobosDBCheckpoint::EventHelper

Class Method Details

.exists?(checksum) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/phobos_db_checkpoint/failure.rb', line 30

def self.exists?(checksum)
  where(checksum: checksum).exists?
end

.record(event:, event_metadata:, exception: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/phobos_db_checkpoint/failure.rb', line 11

def self.record(event:, event_metadata:, exception: nil)
  return if exists?([:checksum])

  create do |record|
    record.topic           = [:topic]
    record.group_id        = [:group_id]
    record.entity_id       = event.fetch_entity_id
    record.event_time      = event.fetch_event_time
    record.event_type      = event.fetch_event_type
    record.event_version   = event.fetch_event_version
    record.checksum        = [:checksum]
    record.payload         = event.payload
    record.        = 
    record.error_class     = exception&.class&.name
    record.error_message   = exception&.message
    record.error_backtrace = exception&.backtrace
  end
end

Instance Method Details

#group_idObject



42
43
44
# File 'lib/phobos_db_checkpoint/failure.rb', line 42

def group_id
  attributes['group_id'] || [:group_id]
end

#metadataObject



38
39
40
# File 'lib/phobos_db_checkpoint/failure.rb', line 38

def 
  attributes['metadata'].deep_symbolize_keys
end

#payloadObject



34
35
36
# File 'lib/phobos_db_checkpoint/failure.rb', line 34

def payload
  attributes['payload'].deep_symbolize_keys
end