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 :auto mode.

Constant Summary collapse

CHAIN =

Ordered list of concrete request strategies attempted by auto mode.

%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



33
34
35
36
37
38
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 33

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



42
43
44
45
46
47
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 42

def call
  state, attempts = run_attempts
  return state if state

  finalize_failure(attempts:)
end