Class: Html2rss::FeedPipeline::AutoFallback

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

Overview

Retries feed extraction across concrete request strategies for the :auto plan.

Owned by Html2rss::FeedPipeline; invoked only after StrategyPlan resolves :auto.

Defined Under Namespace

Classes: AttemptState

Constant Summary collapse

CHAIN =

Ordered list of concrete request strategies attempted by the :auto plan.

%i[faraday botasaurus browserless].freeze
NON_FALLBACK_ERRORS =

Error classes that should abort auto fallback immediately.

[
  RequestService::UnknownStrategy,
  RequestService::InvalidUrl,
  RequestService::UnsupportedUrlScheme,
  RequestService::UnsupportedResponseContentType,
  RequestService::RequestBudgetExceeded,
  RequestService::PrivateNetworkDenied,
  RequestService::CrossOriginFollowUpDenied,
  RequestService::ResponseTooLarge,
  RequestService::BrowserlessConfigurationError
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(strategies:, budget:, session_for:, articles_for:) ⇒ void

Parameters:

  • strategies (Array<Symbol>)

    ordered concrete strategies for fallback

  • budget (RequestService::Budget)

    shared request budget across retries

  • session_for (Proc)

    request session factory proc

  • articles_for (Proc)

    article extraction proc



66
67
68
69
70
71
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 66

def initialize(strategies:, budget:, session_for:, articles_for:)
  @strategies = strategies
  @budget = budget
  @session_for = session_for
  @articles_for = articles_for
end

Instance Method Details

#callHash{Symbol => Object}

Returns pipeline state containing :response and :articles.

Returns:

  • (Hash{Symbol => Object})

    pipeline state containing :response and :articles



75
76
77
78
79
80
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 75

def call
  state = run_attempts
  return state.result if state.succeeded?

  finalize_failure(attempts: state.attempts)
end