Class: Html2rss::FeedPipeline::AutoFallback::AttemptState
- Inherits:
-
Object
- Object
- Html2rss::FeedPipeline::AutoFallback::AttemptState
- Defined in:
- lib/html2rss/feed_pipeline/auto_fallback.rb
Overview
Mutable run state for one auto-fallback chain: attempts plus selected result.
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#entry_resolution ⇒ Object
readonly
Returns the value of attribute entry_resolution.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ AttemptState
constructor
A new instance of AttemptState.
- #mark_resolution_tried! ⇒ void
- #record_error(strategy:, error:) ⇒ void
- #record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
- #remember_entry_resolution(result) ⇒ void
- #remember_response(response) ⇒ void
-
#resolution_tried? ⇒ Boolean
Whether entry resolution already ran for this chain.
-
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, scrape_target:, admission_drops: {}) ⇒ void
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength -- PipelineOutcome kwargs stay co-located.
-
#succeeded? ⇒ Boolean
True when a strategy already yielded items.
Constructor Details
#initialize ⇒ AttemptState
Returns a new instance of AttemptState.
29 30 31 32 33 34 35 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 29 def initialize @attempts = [] @result = nil @last_response = nil @entry_resolution = nil @resolution_tried = false end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
27 28 29 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 27 def attempts @attempts end |
#entry_resolution ⇒ Object (readonly)
Returns the value of attribute entry_resolution.
27 28 29 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 27 def entry_resolution @entry_resolution end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
27 28 29 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 27 def last_response @last_response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
27 28 29 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 27 def result @result end |
Instance Method Details
#mark_resolution_tried! ⇒ void
This method returns an undefined value.
44 45 46 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 44 def mark_resolution_tried! @resolution_tried = true end |
#record_error(strategy:, error:) ⇒ void
This method returns an undefined value.
57 58 59 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 57 def record_error(strategy:, error:) @attempts << { strategy:, items_count: nil, error_class: error.class.name } end |
#record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
This method returns an undefined value.
65 66 67 68 69 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 65 def record_items(strategy:, items_count:, transport_meta: nil) attempt = { strategy:, items_count:, error_class: nil } attempt[:transport_meta] = if && !.empty? @attempts << attempt end |
#remember_entry_resolution(result) ⇒ void
This method returns an undefined value.
50 51 52 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 50 def remember_entry_resolution(result) @entry_resolution = FeedResolution::Diag.from_result(result) end |
#remember_response(response) ⇒ void
This method returns an undefined value.
73 74 75 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 73 def remember_response(response) @last_response = response end |
#resolution_tried? ⇒ Boolean
Returns whether entry resolution already ran for this chain.
41 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 41 def resolution_tried? = @resolution_tried |
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, scrape_target:, admission_drops: {}) ⇒ void
This method returns an undefined value.
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength -- PipelineOutcome kwargs stay co-located
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 86 def succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, scrape_target:, admission_drops: {}) @result = PipelineOutcome.new( response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, strategy_attempts: attempts, admission_drops:, scrape_target:, entry_resolution: ) end |
#succeeded? ⇒ Boolean
Returns true when a strategy already yielded items.
38 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 38 def succeeded? = !result.nil? |