Class: Wellness::Services::RedisService
- Defined in:
- lib/wellness/services/redis_service.rb
Constant Summary collapse
- KEYS =
[ 'used_memory_human', 'connected_clients', 'keyspace_misses', 'keyspace_hits', 'evicted_keys', 'expired_keys', 'sync_partial_err', 'sync_partial_ok', 'sync_full', 'rejected_connections', 'total_commands_processed', 'total_connections_received', 'uptime_in_seconds', 'uptime_in_days' ]
Instance Method Summary collapse
- #call ⇒ Hash
- #failed(error) ⇒ Object
-
#initialize(args = {}) ⇒ RedisService
constructor
A new instance of RedisService.
Methods inherited from Base
Constructor Details
#initialize(args = {}) ⇒ RedisService
Returns a new instance of RedisService.
23 24 25 |
# File 'lib/wellness/services/redis_service.rb', line 23 def initialize(args={}) @params = args end |
Instance Method Details
#call ⇒ Hash
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wellness/services/redis_service.rb', line 28 def call client = Redis.new(@params) details = client.info.select { |k, _| KEYS.include?(k) } client.quit { 'status' => 'HEALTHY', 'details' => details } rescue Redis::BaseError => error failed(error) rescue Exception => error failed(error) end |
#failed(error) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/wellness/services/redis_service.rb', line 43 def failed(error) { 'status' => 'UNHEALTHY', 'details' => { 'error' => error. } } end |