Class: Textus::Produce::Acquire::Intake
- Inherits:
-
Object
- Object
- Textus::Produce::Acquire::Intake
- Defined in:
- lib/textus/produce/acquire/intake.rb
Overview
Internal ingest executor for one machine-zone intake entry. No longer a public verb (ADR 0079 collapsed the ‘fetch` surface): used by the `reconcile` sweep and `textus hook run` only — ingest is system-pushed (ADR 0089 removed the read-through that once also drove it).
Constant Summary collapse
- FETCH_TIMEOUT_SECONDS =
Textus::Produce::Acquire::Handler::FETCH_TIMEOUT_SECONDS
Class Method Summary collapse
Instance Method Summary collapse
-
#call(key) ⇒ Object
call(key) is the primary entry; run is kept as an alias for Orchestrator and FetchAll which call worker.run(key).
-
#initialize(container:, call:) ⇒ Intake
constructor
A new instance of Intake.
- #run(key) ⇒ Object
Constructor Details
#initialize(container:, call:) ⇒ Intake
Returns a new instance of Intake.
13 14 15 16 17 18 19 |
# File 'lib/textus/produce/acquire/intake.rb', line 13 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest @schemas = container.schemas @rpc = container.rpc end |
Class Method Details
.normalize_action_result(res, format:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/textus/produce/acquire/intake.rb', line 39 def self.normalize_action_result(res, format:) res = res.transform_keys(&:to_s) if res.is_a?(Hash) res ||= {} = res["_meta"] body = res["body"] content = res["content"] case format when "markdown" then { meta: || {}, body: body.to_s, content: nil } when "text" then { meta: {}, body: body.to_s, content: nil } when "json", "yaml" if !content.nil? { meta: || {}, body: nil, content: content } elsif !body.nil? { meta: {}, body: body.to_s, content: nil } else raise Textus::UsageError.new("intake for #{format} returned neither content nor body") end else raise Textus::UsageError.new("unknown format #{format.inspect}") end end |
Instance Method Details
#call(key) ⇒ Object
call(key) is the primary entry; run is kept as an alias for Orchestrator and FetchAll which call worker.run(key).
23 24 25 |
# File 'lib/textus/produce/acquire/intake.rb', line 23 def call(key) run(key) end |
#run(key) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/textus/produce/acquire/intake.rb', line 27 def run(key) res = @manifest.resolver.resolve(key) mentry = res.entry path = res.path remaining = res.remaining raise UsageError.new("no intake declared for '#{key}'") unless mentry.intake? before_etag = @container.file_store.exists?(path) ? @container.file_store.etag(path) : nil result = fetch_with_events(key, mentry, remaining) persist_and_notify(key, mentry, result, before_etag) end |