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.
-
#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.
- #record_error(strategy:, error:) ⇒ void
- #record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
- #remember_response(response) ⇒ void
-
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, admission_drops: {}) ⇒ void
rubocop:disable Metrics/ParameterLists -- 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 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 29 def initialize @attempts = [] @result = nil @last_response = nil 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 |
#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
#record_error(strategy:, error:) ⇒ void
This method returns an undefined value.
41 42 43 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 41 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.
49 50 51 52 53 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 49 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_response(response) ⇒ void
This method returns an undefined value.
57 58 59 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 57 def remember_response(response) @last_response = response end |
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, admission_drops: {}) ⇒ void
This method returns an undefined value.
rubocop:disable Metrics/ParameterLists -- PipelineOutcome kwargs stay co-located
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 69 def succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, admission_drops: {}) @result = PipelineOutcome.new( response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, strategy_attempts: attempts, admission_drops: ) end |
#succeeded? ⇒ Boolean
Returns true when a strategy already yielded items.
36 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 36 def succeeded? = !result.nil? |