Module: Textus::Write::IntakeFetch

Defined in:
lib/textus/write/intake_fetch.rb

Overview

Invokes a :resolve_intake hook handler by name under a timeout. The transport-side fetch kernel shared by ‘textus put –fetch` and `textus hook run`. Maps Timeout::Error to a UsageError; leaves any other error to the caller (call sites differ in how they wrap those).

Constant Summary collapse

FETCH_TIMEOUT_SECONDS =
30

Class Method Summary collapse

Class Method Details

.invoke(rpc:, handler:, config:, args:, label:, timeout: FETCH_TIMEOUT_SECONDS) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/textus/write/intake_fetch.rb', line 14

def invoke(rpc:, handler:, config:, args:, label:, timeout: FETCH_TIMEOUT_SECONDS)
  Timeout.timeout(timeout) do
    rpc.invoke(:resolve_intake, handler, caps: nil, config: config, args: args)
  end
rescue Timeout::Error
  raise Textus::UsageError.new("#{label} '#{handler}' exceeded #{timeout}s timeout")
end