This module handles the request queueing on hydra.
@api private
Abort the current hydra run as good as possible. This means that it only clears the queued requests and can’t do anything about already running requests.
@example Abort hydra.
hydra.abort
# File lib/typhoeus/hydra/queueable.rb, line 27 def abort queued_requests.clear end
Removes a request from queued_requests and adds it to the hydra in order to be performed next.
@example Dequeue request.
hydra.dequeue
@since 0.6.4
# File lib/typhoeus/hydra/queueable.rb, line 62 def dequeue add(queued_requests.shift) unless queued_requests.empty? end
Removes requests from queued_requests and adds them to the hydra until max_concurrency is reached.
@example Dequeue requests.
hydra.dequeue_many
@since 0.6.8
# File lib/typhoeus/hydra/queueable.rb, line 74 def dequeue_many number = multi.easy_handles.count until number == max_concurrency || queued_requests.empty? add(queued_requests.shift) number += 1 end end
Enqueues a request in order to be performed by the hydra. This can even be done while the hydra is running. Also sets hydra on request.
@example Queue request.
hydra.queue(request)
# File lib/typhoeus/hydra/queueable.rb, line 38 def queue(request) request.hydra = self queued_requests << request end
Pushes a request to the front of the queue, to be performed by the hydra. Also sets hydra on request
@example Queue reques.
hydra.queue_front(request)
# File lib/typhoeus/hydra/queueable.rb, line 49 def queue_front(request) request.hydra = self queued_requests.unshift request end
Generated with the Darkfish Rdoc Generator 2.