Class: SourceMonitor::Health::ImportSourceHealthCheck
- Inherits:
-
Object
- Object
- SourceMonitor::Health::ImportSourceHealthCheck
- Defined in:
- lib/source_monitor/health/import_source_health_check.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(feed_url:, client: nil) ⇒ ImportSourceHealthCheck
constructor
A new instance of ImportSourceHealthCheck.
Constructor Details
#initialize(feed_url:, client: nil) ⇒ ImportSourceHealthCheck
Returns a new instance of ImportSourceHealthCheck.
8 9 10 11 |
# File 'lib/source_monitor/health/import_source_health_check.rb', line 8 def initialize(feed_url:, client: nil) @feed_url = feed_url @client = client end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/source_monitor/health/import_source_health_check.rb', line 13 def call return Result.new(status: "failing", error_message: "Missing feed URL", http_status: nil) if feed_url.blank? response = connection.get(feed_url) status_code = response_status(response) healthy = healthy_status?(status_code) Result.new( status: healthy ? "working" : "failing", error_message: healthy ? nil : error_for_status(status_code), http_status: status_code ) rescue StandardError => error Result.new(status: "failing", error_message: error., http_status: response_status(error)) end |