Class: Textus::Store::Staleness::IntakeCheck
- Inherits:
-
Object
- Object
- Textus::Store::Staleness::IntakeCheck
- Defined in:
- lib/textus/store/staleness/intake_check.rb
Overview
Reports TTL-exceeded staleness for intake-handler entries. Returns an Array of row hashes (possibly empty) per entry.
Instance Method Summary collapse
-
#initialize(manifest:) ⇒ IntakeCheck
constructor
A new instance of IntakeCheck.
- #rows_for(mentry) ⇒ Object
Constructor Details
#initialize(manifest:) ⇒ IntakeCheck
Returns a new instance of IntakeCheck.
9 10 11 |
# File 'lib/textus/store/staleness/intake_check.rb', line 9 def initialize(manifest:) @manifest = manifest end |
Instance Method Details
#rows_for(mentry) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/textus/store/staleness/intake_check.rb', line 13 def rows_for(mentry) return [] unless mentry.intake_handler ttl = @manifest.policies_for(mentry.key).refresh&.ttl_seconds return [] unless ttl path = Textus::Key::Path.resolve(@manifest, mentry) return [row(mentry, path, "never refreshed")] unless File.exist?(path) = Entry.for_format(mentry.format).parse(File.binread(path), path: path)["_meta"] last_str = ["last_refreshed_at"] return [row(mentry, path, "never refreshed (no last_refreshed_at)")] if last_str.nil? last = parse_time(last_str) return [row(mentry, path, "ttl exceeded (#{ttl}s)")] if last.nil? || (Time.now - last) > ttl [] end |