Class: Sidekiq::MemoryGuardRestartTracker
- Inherits:
-
Object
- Object
- Sidekiq::MemoryGuardRestartTracker
- Defined in:
- lib/sidekiq/memory_guard_restart_tracker.rb
Overview
Maintains cross-process restart markers for one Sidekiq role. The process
requesting a restart writes the marker; its replacement consumes it and
reports the completed lifecycle without coupling Redis to the guard loop.
Constant Summary collapse
- RESTART_WINDOW_SECONDS =
60 * 60
- RESTART_WINDOW_TTL_SECONDS =
2 * RESTART_WINDOW_SECONDS
Instance Method Summary collapse
- #clear_pending_restart ⇒ void
-
#initialize(role:, telemetry: MemoryGuardTelemetry.new(role:)) ⇒ MemoryGuardRestartTracker
constructor
A new instance of MemoryGuardRestartTracker.
- #record_restart_claim ⇒ void
- #record_startup ⇒ void
Constructor Details
#initialize(role:, telemetry: MemoryGuardTelemetry.new(role:)) ⇒ MemoryGuardRestartTracker
Returns a new instance of MemoryGuardRestartTracker.
15 16 17 18 |
# File 'lib/sidekiq/memory_guard_restart_tracker.rb', line 15 def initialize(role:, telemetry: MemoryGuardTelemetry.new(role:)) @role = role.to_s @telemetry = telemetry end |
Instance Method Details
#clear_pending_restart ⇒ void
This method returns an undefined value.
40 41 42 43 44 |
# File 'lib/sidekiq/memory_guard_restart_tracker.rb', line 40 def clear_pending_restart Sidekiq.redis { |connection| connection.call('DEL', pending_restart_key) } rescue StandardError => e log_failure(e) end |
#record_restart_claim ⇒ void
This method returns an undefined value.
32 33 34 35 36 37 |
# File 'lib/sidekiq/memory_guard_restart_tracker.rb', line 32 def record_restart_claim now = Time.now.to_f @telemetry.record_restart_count(update_restart_window(now)) rescue StandardError => e log_failure(e) end |
#record_startup ⇒ void
This method returns an undefined value.
21 22 23 24 25 26 27 28 29 |
# File 'lib/sidekiq/memory_guard_restart_tracker.rb', line 21 def record_startup restarted_at = safely_fetch_pending_restart now = Time.now.to_f record_startup_metrics(restarted_at:, now:) record_startup_event(restarted_at:, now:) rescue StandardError => e log_failure(e, prefix: 'startup') end |