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:, bus:) ⇒ Worker

Returns a new instance of Worker.



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

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

Instance Method Details

#run(key) ⇒ Object

Raises:



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

def run(key)
  mentry, path, = @ctx.store.manifest.resolve(key)
  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)
  persist_and_notify(key, mentry, result, before_etag)
end