lib/hotseat/queue.rb in hotseat-0.5.0 vs lib/hotseat/queue.rb in hotseat-0.5.1
- old
+ new
@@ -129,17 +129,17 @@
def num_pending
@db.view(pending_view_name, :limit => 0)['total_rows']
end
alias :size :num_pending
- def get(n=1, as_stack=false)
- params = {:limit => n, :include_docs => true, :descending => as_stack}
+ def get(n=1, options={})
+ params = {:limit => n, :include_docs => true}.merge(options)
rows = @db.view(pending_view_name, params)['rows']
rows.map{|row| row['doc']} unless rows.empty?
end
- def lease(n=1)
- if docs = get(n)
+ def lease(n=1, query_options={})
+ if docs = get(n, query_options)
docs.each {|doc| add_lock doc }
response = @db.bulk_save docs, use_uuids=false
# Some docs may have failed to lock - probably updated by another process
locked_ids = response.reject{|res| res['error']}.map{|res| res['id']}
if locked_ids.length < docs.length