Module: IronCuke::Queue

Included in:
IronCuke
Defined in:
lib/iron_cuke/queue.rb

Instance Method Summary collapse

Instance Method Details

#clear_queueObject



26
27
28
# File 'lib/iron_cuke/queue.rb', line 26

def clear_queue
	worker_queue.clear
end

#queue(worker, options) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
18
19
20
21
22
23
24
# File 'lib/iron_cuke/queue.rb', line 15

def queue(worker, options)
	options = {:priority => 0}.merge(options)
	raise NotImplementedError unless options[:priority].between?(0,2)

	worker_queue[options[:priority]] ||= []
	item = IronCuke::QueueItem.new(worker, options)
	worker_queue[options[:priority]] << item
	worker.task_id = item.id
	response = IronCuke::Queue.create_response(item)
end

#queued(priority = 0) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
# File 'lib/iron_cuke/queue.rb', line 6

def queued(priority = 0)
	raise ArgumentError unless priority.between?(0,2)
	worker_queue.select{|p, workers| p >= priority}.values.map { |p| 
		p.map { |data| 
			data.worker 
		} 
	}.flatten
end