Class: Sqeduler::TriggerLock
- Defined in:
- lib/sqeduler/trigger_lock.rb
Overview
Super simple facade to match RufusScheduler's expectations of how a trigger_lock behaves.
Constant Summary collapse
- SCHEDULER_LOCK_KEY =
"sidekiq_scheduler_lock".freeze
Constants inherited from RedisLock
Instance Attribute Summary
Attributes inherited from RedisLock
Instance Method Summary collapse
-
#initialize ⇒ TriggerLock
constructor
A new instance of TriggerLock.
- #lock ⇒ Object
Methods inherited from RedisLock
#expiration_milliseconds, #locked?, #refresh, #unlock, with_lock
Methods included from RedisScripts
Constructor Details
#initialize ⇒ TriggerLock
Returns a new instance of TriggerLock.
8 9 10 |
# File 'lib/sqeduler/trigger_lock.rb', line 8 def initialize super(SCHEDULER_LOCK_KEY, :expiration => 60, :timeout => 0) end |
Instance Method Details
#lock ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/sqeduler/trigger_lock.rb', line 12 def lock # Locking should: # - not block # - return true if already acquired # - refresh the lock if already acquired refresh || super rescue false end |