Skip to content

Commit

Permalink
Merge pull request resque#366 from resque/merging-v2.x-stable
Browse files Browse the repository at this point in the history
Merging v2.x stable
  • Loading branch information
Matteo Centenaro committed Feb 18, 2014
2 parents e0e91aa + 08c1a45 commit 2f208d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/resque/scheduler/lock/resilient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def locked?
).to_i == 1
end

def timeout=(t)
@timeout = t if locked?
end

private

def locked_sha(refresh = false)
Expand Down
6 changes: 5 additions & 1 deletion lib/resque_scheduler/server/views/delayed.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
<% end %>
</td>
<td><%= h(job['args'].inspect) if job && delayed_timestamp_size == 1 %></td>
<td><a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a></td>
<td>
<% if job %>
<a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
<% end %>
</td>
</tr>
<% end %>
</table>
Expand Down
20 changes: 20 additions & 0 deletions test/scheduler_locking_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,25 @@ def lock_is_not_held(lock)
assert Resque.redis.ttl(@lock.key) <= 10,
'TTL should not have been updated'
end

test 'setting the lock timeout changes the key TTL if we hold it' do
@lock.acquire!

@lock.timeout = 120
ttl = Resque.redis.ttl(@lock.key)
assert_send [ttl, :>, 100]

@lock.timeout = 180
ttl = Resque.redis.ttl(@lock.key)
assert_send [ttl, :>, 120]
end

test 'setting the lock timeout is a noop if not held' do
@lock.acquire!
@lock.timeout = 100
@lock.stubs(:locked?).returns(false)
@lock.timeout = 120
assert_equal 100, @lock.timeout
end
end
end

0 comments on commit 2f208d0

Please sign in to comment.