Class: SourceMonitor::Fetching::FeedFetcher
- Inherits:
-
Object
- Object
- SourceMonitor::Fetching::FeedFetcher
- Defined in:
- lib/source_monitor/fetching/feed_fetcher.rb,
lib/source_monitor/fetching/feed_fetcher/source_updater.rb,
lib/source_monitor/fetching/feed_fetcher/entry_processor.rb,
lib/source_monitor/fetching/feed_fetcher/failure_outcome.rb,
lib/source_monitor/fetching/feed_fetcher/success_outcome.rb,
lib/source_monitor/fetching/feed_fetcher/adaptive_interval.rb
Defined Under Namespace
Classes: AdaptiveInterval, EntryProcessingResult, EntryProcessor, FailureOutcome, ResponseWrapper, Result, SourceUpdater, SuccessOutcome
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#jitter_proc ⇒ Object
readonly
Returns the value of attribute jitter_proc.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(source:, client: nil, jitter: nil) ⇒ FeedFetcher
constructor
A new instance of FeedFetcher.
Constructor Details
#initialize(source:, client: nil, jitter: nil) ⇒ FeedFetcher
Returns a new instance of FeedFetcher.
47 48 49 50 51 |
# File 'lib/source_monitor/fetching/feed_fetcher.rb', line 47 def initialize(source:, client: nil, jitter: nil) @source = source @client = client @jitter_proc = jitter end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
45 46 47 |
# File 'lib/source_monitor/fetching/feed_fetcher.rb', line 45 def client @client end |
#jitter_proc ⇒ Object (readonly)
Returns the value of attribute jitter_proc.
45 46 47 |
# File 'lib/source_monitor/fetching/feed_fetcher.rb', line 45 def jitter_proc @jitter_proc end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
45 46 47 |
# File 'lib/source_monitor/fetching/feed_fetcher.rb', line 45 def source @source end |
Instance Method Details
#call ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/source_monitor/fetching/feed_fetcher.rb', line 53 def call attempt_started_at = Time.current instrumentation_payload = base_instrumentation_payload started_monotonic = SourceMonitor::Instrumentation.monotonic_time result = nil SourceMonitor::Instrumentation.fetch_start(instrumentation_payload) result = perform_fetch(attempt_started_at, instrumentation_payload) rescue FetchError => error result = handle_failure(error, started_at: attempt_started_at, instrumentation_payload:) rescue StandardError => error fetch_error = UnexpectedResponseError.new(error., original_error: error) result = handle_failure(fetch_error, started_at: attempt_started_at, instrumentation_payload:) ensure instrumentation_payload[:duration_ms] ||= duration_since(started_monotonic) SourceMonitor::Instrumentation.fetch_finish(instrumentation_payload) return result end |