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
- #abort! ⇒ void
-
#aborted? ⇒ Boolean
Whether attempts were aborted due to deterministic errors.
-
#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-next 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.
33 34 35 36 37 38 39 40 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 33 def initialize @attempts = [] @result = nil @last_response = nil @entry_resolution = nil @resolution_tried = false @aborted = false end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
31 32 33 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 31 def attempts @attempts end |
#entry_resolution ⇒ Object (readonly)
Returns the value of attribute entry_resolution.
31 32 33 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 31 def entry_resolution @entry_resolution end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
31 32 33 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 31 def last_response @last_response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
31 32 33 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 31 def result @result end |
Instance Method Details
#abort! ⇒ void
This method returns an undefined value.
49 50 51 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 49 def abort! @aborted = true end |
#aborted? ⇒ Boolean
Returns whether attempts were aborted due to deterministic errors.
46 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 46 def aborted? = @aborted |
#mark_resolution_tried! ⇒ void
This method returns an undefined value.
57 58 59 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 57 def mark_resolution_tried! @resolution_tried = true end |
#record_error(strategy:, error:) ⇒ void
This method returns an undefined value.
70 71 72 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 70 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.
78 79 80 81 82 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 78 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.
63 64 65 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 63 def remember_entry_resolution(result) @entry_resolution = FeedResolution::Diag.from_result(result) end |
#remember_response(response) ⇒ void
This method returns an undefined value.
86 87 88 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 86 def remember_response(response) @last_response = response end |
#resolution_tried? ⇒ Boolean
Returns whether entry resolution already ran for this chain.
54 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 54 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-next Metrics/ParameterLists, Metrics/MethodLength -- PipelineOutcome kwargs stay co-located
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 99 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.
43 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 43 def succeeded? = !result.nil? |