Class: PerfectQueue::Queue
- Inherits:
-
Object
- Object
- PerfectQueue::Queue
- Includes:
- Enumerable, Model
- Defined in:
- lib/perfectqueue/queue.rb
Instance Attribute Summary
Attributes included from Model
Instance Method Summary collapse
- #[](key) ⇒ Object
- #close ⇒ Object
- #each(options = {}, &block) ⇒ Object
-
#initialize(client) ⇒ Queue
constructor
A new instance of Queue.
- #poll(options = {}) ⇒ Object
- #poll_multi(options = {}) ⇒ Object
- #submit(key, type, data, options = {}) ⇒ Object
Methods included from Model
Constructor Details
#initialize(client) ⇒ Queue
Returns a new instance of Queue.
23 24 25 |
# File 'lib/perfectqueue/queue.rb', line 23 def initialize(client) super(client) end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'lib/perfectqueue/queue.rb', line 27 def [](key) Task.new(@client, key) end |
#close ⇒ Object
53 54 55 |
# File 'lib/perfectqueue/queue.rb', line 53 def close client.close end |
#each(options = {}, &block) ⇒ Object
31 32 33 |
# File 'lib/perfectqueue/queue.rb', line 31 def each(={}, &block) @client.list(, &block) end |
#poll(options = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/perfectqueue/queue.rb', line 37 def poll(={}) = .merge({:max_acquire=>1}) if acquired = poll_multi() return acquired[0] end return nil end |
#poll_multi(options = {}) ⇒ Object
45 46 47 |
# File 'lib/perfectqueue/queue.rb', line 45 def poll_multi(={}) @client.acquire() end |
#submit(key, type, data, options = {}) ⇒ Object
49 50 51 |
# File 'lib/perfectqueue/queue.rb', line 49 def submit(key, type, data, ={}) @client.submit(key, type, data, ) end |