Class: Textus::Application::Refresh::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/refresh/worker.rb

Constant Summary collapse

FETCH_TIMEOUT_SECONDS =
30

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, envelope_io:) ⇒ Worker

Returns a new instance of Worker.



9
10
11
12
# File 'lib/textus/application/refresh/worker.rb', line 9

def initialize(ctx:, envelope_io:)
  @ctx = ctx
  @envelope_io = envelope_io
end

Instance Method Details

#run(key) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/textus/application/refresh/worker.rb', line 14

def run(key)
  res = @ctx.store.manifest.resolve(key)
  mentry = res.entry
  path = res.path
  remaining = res.remaining
  raise UsageError.new("no intake declared for '#{key}'") unless mentry.intake_handler

  before_etag = File.exist?(path) ? Etag.for_file(path) : nil
  result = fetch_with_bus(key, mentry, remaining)
  persist_and_notify(key, mentry, result, before_etag)
end