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

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)


28
29
30
# File 'lib/phobos_db_checkpoint/failure.rb', line 28

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

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



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

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



40
41
42
# File 'lib/phobos_db_checkpoint/failure.rb', line 40

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

#metadataObject



36
37
38
# File 'lib/phobos_db_checkpoint/failure.rb', line 36

def 
  attributes['metadata'].deep_symbolize_keys
end

#payloadObject



32
33
34
# File 'lib/phobos_db_checkpoint/failure.rb', line 32

def payload
  attributes['payload'].deep_symbolize_keys
end