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:
parent
4ff807e4d1
commit
2891a268a7
3 changed files with 11 additions and 8 deletions
|
@ -44,13 +44,6 @@ module Sidetiq
|
||||||
end.to_json
|
end.to_json
|
||||||
end
|
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
|
def to_s
|
||||||
"Sidetiq::Lock on #{key} set at #{timestamp} by #{owner}"
|
"Sidetiq::Lock on #{key} set at #{timestamp} by #{owner}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,16 @@ module Sidetiq
|
||||||
end
|
end
|
||||||
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
|
def meta_data
|
||||||
@meta_data ||= Sidekiq.redis do |redis|
|
@meta_data ||= Sidekiq.redis do |redis|
|
||||||
MetaData.from_json(redis.get(key))
|
MetaData.from_json(redis.get(key))
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<% @locks.each do |meta| %>
|
<% @locks.each do |meta| %>
|
||||||
<% pttl = meta.pttl %>
|
<% pttl = meta.pttl %>
|
||||||
|
|
||||||
<tr class="<%= 'error' if meta.stale? %>">
|
<tr>
|
||||||
<td><%= meta.key %></td>
|
<td><%= meta.key %></td>
|
||||||
<td><%= meta.owner %></td>
|
<td><%= meta.owner %></td>
|
||||||
<td><%= meta.timestamp.to_i %></td>
|
<td><%= meta.timestamp.to_i %></td>
|
||||||
|
|
Loading…
Reference in a new issue