Class: ExternalServicesRedis::Status
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- ExternalServicesRedis::Status
- Includes:
- Common::CacheAside
- Defined in:
- app/models/external_services_redis/status.rb
Overview
Facade for the PagerDuty::ExternalServices::Service class.
Constant Summary collapse
- KEY =
'pager_duty_services'
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Instance Method Summary collapse
-
#fetch_or_cache ⇒ PagerDuty::ExternalServices::Response
Returns either the cached response from the PagerDuty::ExternalServices::Service.new.get_services call, or makes a fresh call to that endpoint, then caches and returns the response.
-
#reported_at ⇒ Time
The time from the call to PagerDuty’s API.
- #response_from_redis_or_service ⇒ Object private
-
#response_status ⇒ Integer
The HTTP status code from call to PagerDuty’s API.
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with, #set_attributes
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Instance Method Details
#fetch_or_cache ⇒ PagerDuty::ExternalServices::Response
Returns either the cached response from the PagerDuty::ExternalServices::Service.new.get_services call, or makes a fresh call to that endpoint, then caches and returns the response.
45 46 47 |
# File 'app/models/external_services_redis/status.rb', line 45 def fetch_or_cache @response ||= response_from_redis_or_service end |
#reported_at ⇒ Time
The time from the call to PagerDuty’s API
22 |
# File 'app/models/external_services_redis/status.rb', line 22 delegate :reported_at, to: :fetch_or_cache |
#response_from_redis_or_service ⇒ Object (private)
59 60 61 62 63 |
# File 'app/models/external_services_redis/status.rb', line 59 def response_from_redis_or_service do_cached_with(key: KEY) do PagerDuty::ExternalServices::Service.new.get_services end end |
#response_status ⇒ Integer
The HTTP status code from call to PagerDuty’s API
53 54 55 |
# File 'app/models/external_services_redis/status.rb', line 53 def response_status fetch_or_cache.status end |