0.0
No commit activity in last 3 years
No release in over 3 years
A queue that refreshes itself when it gets empty or stale, so you can keep popping
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
~> 2

Runtime

~> 3.0
 Project Readme

A queue that refreshes itself when it gets empty or stale, so you can keep popping

Install

gem install refilling_queue

Usage

queue = RefillingQueue.new redis_client, "my_queue", refresh_every: 30.seconds do
  expensive_operation.map(&:id)
end

begin
  queue.pop
rescue RefillingQueue::Locked
  # queue was empty, refilling failed because other process is already trying it
end

queue.pop -> return id
... # queue empty ?
queue.pop -> run block -> store new ids -> return id
... # 30 seconds elapsed (global expires_at stored in reque_client) ?
queue.pop -> run block -> store new ids -> return id
...
queue.pop -> run block -> empty result -> return nil

Pagination

queue = RefillingQueue.new redis_client, "my_queue", refresh_every: 30.seconds, paginate: true do |page|
  expensive_operation(:page => page).map(&:id)
end

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status