Class: SidekiqVigil::Check::RedisHealth

Inherits:
Base
  • Object
show all
Defined in:
lib/sidekiq_vigil/check/redis_health.rb

Instance Attribute Summary

Attributes inherited from Base

#api, #clock, #logger, #options, #storage

Instance Method Summary collapse

Methods inherited from Base

#check_name, #execute

Constructor Details

#initialize(storage:, options: {}, clock: -> { Time.now }, logger: SidekiqVigil.logger, api: SidekiqApi.new, monotonic_clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }) ⇒ RedisHealth

Returns a new instance of RedisHealth.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sidekiq_vigil/check/redis_health.rb', line 6

def initialize(
  storage:,
  options: {},
  clock: -> { Time.now },
  logger: SidekiqVigil.logger,
  api: SidekiqApi.new,
  monotonic_clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }
)
  super(storage:, options:, clock:, logger:, api:)
  @monotonic_clock = monotonic_clock
end

Instance Method Details

#callObject



18
19
20
21
22
23
# File 'lib/sidekiq_vigil/check/redis_health.rb', line 18

def call
  started_at = monotonic_clock.call
  storage.ping
  latency_ms = (monotonic_clock.call - started_at) * 1_000
  [latency_result(latency_ms), memory_result]
end