Class: EventMeter::Stores::Rollup::File::ProcessedSidecar
- Inherits:
-
Object
- Object
- EventMeter::Stores::Rollup::File::ProcessedSidecar
- Includes:
- FileHelpers
- Defined in:
- lib/event_meter/stores/rollup/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #batch_paths ⇒ Object
- #delete ⇒ Object
-
#initialize(path:) ⇒ ProcessedSidecar
constructor
A new instance of ProcessedSidecar.
- #mark(entry_ids, batch_id:, applied_paths:, timestamp:) ⇒ Object
- #old?(before) ⇒ Boolean
- #processed?(entry_id) ⇒ Boolean
- #processed_count ⇒ Object
Constructor Details
#initialize(path:) ⇒ ProcessedSidecar
Returns a new instance of ProcessedSidecar.
641 642 643 |
# File 'lib/event_meter/stores/rollup/file.rb', line 641 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
639 640 641 |
# File 'lib/event_meter/stores/rollup/file.rb', line 639 def path @path end |
Instance Method Details
#batch_paths ⇒ Object
665 666 667 668 669 |
# File 'lib/event_meter/stores/rollup/file.rb', line 665 def batch_paths hash_value(read[BATCHES_KEY]).transform_values do |batch| Array(hash_value(batch)["applied_paths"]).map(&:to_s) end end |
#delete ⇒ Object
682 683 684 685 |
# File 'lib/event_meter/stores/rollup/file.rb', line 682 def delete ::FileUtils.rm_f(path) ::FileUtils.rm_f(lock_path) end |
#mark(entry_ids, batch_id:, applied_paths:, timestamp:) ⇒ Object
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
# File 'lib/event_meter/stores/rollup/file.rb', line 649 def mark(entry_ids, batch_id:, applied_paths:, timestamp:) update do |data| data[STREAM_FILE_KEY] ||= stream_file processed = hash_value(data[PROCESSED_IDS_KEY]) entry_ids.each { |id| processed[id.to_s] = } data[PROCESSED_IDS_KEY] = processed batches = hash_value(data[BATCHES_KEY]) batches[batch_id] = { "processed_at" => , "applied_paths" => applied_paths } data[BATCHES_KEY] = batches end end |
#old?(before) ⇒ Boolean
675 676 677 678 679 680 |
# File 'lib/event_meter/stores/rollup/file.rb', line 675 def old?(before) = hash_value(read[PROCESSED_IDS_KEY]).values return false if .empty? .all? { || processed_entry_old?(, before) } end |
#processed?(entry_id) ⇒ Boolean
645 646 647 |
# File 'lib/event_meter/stores/rollup/file.rb', line 645 def processed?(entry_id) hash_value(read[PROCESSED_IDS_KEY]).key?(entry_id.to_s) end |
#processed_count ⇒ Object
671 672 673 |
# File 'lib/event_meter/stores/rollup/file.rb', line 671 def processed_count hash_value(read[PROCESSED_IDS_KEY]).length end |