Class: Fairway::Queue
- Inherits:
-
Object
- Object
- Fairway::Queue
- Defined in:
- lib/fairway/queue.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#queue_names ⇒ Object
readonly
Returns the value of attribute queue_names.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(connection, *queue_names) ⇒ Queue
constructor
A new instance of Queue.
- #length ⇒ Object
- #pull ⇒ Object
Constructor Details
#initialize(connection, *queue_names) ⇒ Queue
Returns a new instance of Queue.
5 6 7 8 |
# File 'lib/fairway/queue.rb', line 5 def initialize(connection, *queue_names) @connection = connection @queue_names = parse_queue_names(queue_names) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/fairway/queue.rb', line 3 def connection @connection end |
#queue_names ⇒ Object (readonly)
Returns the value of attribute queue_names.
3 4 5 |
# File 'lib/fairway/queue.rb', line 3 def queue_names @queue_names end |
Instance Method Details
#==(other) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fairway/queue.rb', line 18 def ==(other) other.respond_to?(:connection) && other.respond_to?(:queue_names) && connection == other.connection && queue_names == other.queue_names end |
#length ⇒ Object
10 11 12 |
# File 'lib/fairway/queue.rb', line 10 def length @connection.redis.mget(@queue_names.uniq.map{|q| "#{q}:length" }).sum.to_i end |
#pull ⇒ Object
14 15 16 |
# File 'lib/fairway/queue.rb', line 14 def pull @connection.scripts.fairway_pull(@queue_names.shuffle.uniq) end |