Class: Katello::Resources::Candlepin::CandlepinPing

Inherits:
CandlepinResource show all
Defined in:
app/lib/katello/resources/candlepin/candlepin_ping.rb

Constant Summary collapse

CACHE_KEY =
'katello/candlepin_status_response'.freeze
CACHE_TTL =
180.seconds
RACE_TTL =
3.seconds

Constants inherited from HttpResource

HttpResource::REQUEST_MAP

Instance Attribute Summary

Attributes inherited from HttpResource

#json

Class Method Summary collapse

Methods inherited from CandlepinResource

default_headers, fetch_paged, included_list, logger, name_to_key, process_response, raise_rest_client_exception

Methods inherited from HttpResource

#[], #[]=, hash_to_query, #initialize, issue_request, join_path, logger, process_response, raise_rest_client_exception, rest_client

Methods included from Concerns::FilterSensitiveData

#filter_sensitive_data

Constructor Details

This class inherits a constructor from Katello::HttpResource

Class Method Details

.clear_cacheObject



21
22
23
# File 'app/lib/katello/resources/candlepin/candlepin_ping.rb', line 21

def clear_cache
  Rails.cache.delete(CACHE_KEY)
end

.ok?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/lib/katello/resources/candlepin/candlepin_ping.rb', line 17

def ok?
  ping(try_cache: true)['mode'] == 'NORMAL'
end

.ping(try_cache: false) ⇒ Object



10
11
12
13
14
15
# File 'app/lib/katello/resources/candlepin/candlepin_ping.rb', line 10

def ping(try_cache: false)
  Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_TTL, race_condition_ttl: RACE_TTL, force: !try_cache) do
    response = get('/candlepin/status').body
    JSON.parse(response).with_indifferent_access
  end
end