Class: PhobosDBCheckpoint::Failure
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PhobosDBCheckpoint::Failure
show all
- Includes:
- EventHelper
- Defined in:
- lib/phobos_db_checkpoint/failure.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#configured_handler, #configured_listener, #method_missing, #respond_to_missing?
Class Method Details
.exists?(checksum) ⇒ 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?(event_metadata[:checksum])
create do |record|
record.topic = event_metadata[:topic]
record.group_id = event_metadata[: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 = event_metadata[:checksum]
record.payload = event.payload
record.metadata = event_metadata
record.error_class = exception&.class&.name
record.error_message = exception&.message
record.error_backtrace = exception&.backtrace
end
end
|
Instance Method Details
#group_id ⇒ Object
42
43
44
|
# File 'lib/phobos_db_checkpoint/failure.rb', line 42
def group_id
attributes['group_id'] || metadata[:group_id]
end
|
38
39
40
|
# File 'lib/phobos_db_checkpoint/failure.rb', line 38
def metadata
attributes['metadata'].deep_symbolize_keys
end
|
#payload ⇒ Object
34
35
36
|
# File 'lib/phobos_db_checkpoint/failure.rb', line 34
def payload
attributes['payload'].deep_symbolize_keys
end
|