1
0
Fork 0
mirror of https://github.com/endofunky/sidetiq.git synced 2022-11-09 13:53:30 -05:00

Move #stale? from MetaData to Lock::Redis.

This commit is contained in:
Tobias Svensson 2013-09-17 10:42:07 +01:00
parent 4ff807e4d1
commit 2891a268a7
3 changed files with 11 additions and 8 deletions

View file

@ -44,13 +44,6 @@ module Sidetiq
end.to_json
end
def stale?
pttl_cached = pttl
pttl_cached < 0 || pttl_cached >= Sidetiq.config.lock_expire ||
timestamp < (Sidetiq.clock.gettime.to_i - 60)
end
def to_s
"Sidetiq::Lock on #{key} set at #{timestamp} by #{owner}"
end

View file

@ -35,6 +35,16 @@ module Sidetiq
end
end
def stale?
pttl = meta_data.pttl
# Consider PTTL of -1 (never set) and larger than the
# configured lock_expire as invalid. Locks with timestamps
# older than 1 minute are also considered stale.
pttl < 0 || pttl >= Sidetiq.config.lock_expire ||
meta_data.timestamp < (Sidetiq.clock.gettime.to_i - 60)
end
def meta_data
@meta_data ||= Sidekiq.redis do |redis|
MetaData.from_json(redis.get(key))

View file

@ -24,7 +24,7 @@
<% @locks.each do |meta| %>
<% pttl = meta.pttl %>
<tr class="<%= 'error' if meta.stale? %>">
<tr>
<td><%= meta.key %></td>
<td><%= meta.owner %></td>
<td><%= meta.timestamp.to_i %></td>