Class: Html2rss::FeedResolution::Orchestrator

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/feed_resolution.rb

Overview

Tournament + optional retry orchestration for Html2rss::FeedPipeline::AutoFallback.

Constant Summary collapse

MIN_BUDGET_REMAINING =

Minimum remaining request budget required before probing candidates.

3
NON_FALLBACK_ERRORS =

Error classes that abort resolution instead of falling through (mirrors AutoFallback).

FeedPipeline::AutoFallback::NON_FALLBACK_ERRORS

Instance Method Summary collapse

Constructor Details

#initialize(pipeline:, config:, response:, session:, strategy:, resources:, articles:, scrape_target:, state:, budget:) ⇒ Orchestrator

rubocop:disable Metrics/ParameterLists -- orchestration context stays co-located



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/html2rss/feed_resolution.rb', line 93

def initialize(pipeline:, config:, response:, session:, strategy:, resources:, articles:,
               scrape_target:, state:, budget:)
  @pipeline = pipeline
  @config = config
  @response = response
  @session = session
  @strategy = strategy
  @resources = resources
  @articles = articles
  @scrape_target = scrape_target
  @state = state
  @budget = budget
end

Instance Method Details

#callApplyOutcome?

rubocop:disable Metrics/MethodLength -- eligibility + tournament + retry path

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/html2rss/feed_resolution.rb', line 111

def call
  return unless eligible?

  state.mark_resolution_tried!
  resolution = run_tournament
  state.remember_entry_resolution(resolution)
  return unless resolution.applied

  effective = scrape_target.with_effective(resolution.scrape_url)
  return ApplyOutcome.new(scrape_target: effective, status: :succeeded) if retry_with(
    resolution, effective:
  )

  nil
rescue RequestService::RequestBudgetExceeded
  Log.warn('FeedResolution: entry resolution skipped (request budget exhausted)')
  nil
rescue *NON_FALLBACK_ERRORS
  raise
rescue StandardError => error
  Log.warn("FeedResolution: entry resolution retry failed (#{error.class})")
  nil
end