Class: Sqeduler::TriggerLock

Inherits:
RedisLock show all
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

RedisLock::SLEEP_TIME

Instance Attribute Summary

Attributes inherited from RedisLock

#key, #timeout

Instance Method Summary collapse

Methods inherited from RedisLock

#expiration_milliseconds, #locked?, #refresh, #unlock, with_lock

Methods included from RedisScripts

#refresh_lock, #release_lock

Constructor Details

#initializeTriggerLock

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

#lockObject



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