Module: Typhoeus::Hydra::Queueable Private
- Included in:
- Typhoeus::Hydra
- Defined in:
- lib/typhoeus/hydra/queueable.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module handles the request queueing on hydra.
Instance Method Summary collapse
-
#abort ⇒ Object
private
Abort the current hydra run as good as possible.
-
#dequeue ⇒ Object
private
Removes a request from queued_requests and adds it to the hydra in order to be performed next.
-
#dequeue_many ⇒ Object
private
Removes requests from queued_requests and adds them to the hydra until max_concurrency is reached.
-
#queue(request) ⇒ Object
private
Enqueues a request in order to be performed by the hydra.
-
#queue_front(request) ⇒ Object
private
Pushes a request to the front of the queue, to be performed by the hydra.
-
#queued_requests ⇒ Array<Typhoeus::Request>
private
Return the queued requests.
Instance Method Details
#abort ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
27 28 29 |
# File 'lib/typhoeus/hydra/queueable.rb', line 27 def abort queued_requests.clear end |
#dequeue ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a request from queued_requests and adds it to the hydra in order to be performed next.
62 63 64 |
# File 'lib/typhoeus/hydra/queueable.rb', line 62 def dequeue add(queued_requests.shift) unless queued_requests.empty? end |
#dequeue_many ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes requests from queued_requests and adds them to the hydra until max_concurrency is reached.
74 75 76 77 78 79 80 |
# 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 |
#queue(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
38 39 40 41 |
# File 'lib/typhoeus/hydra/queueable.rb', line 38 def queue(request) request.hydra = self queued_requests << request end |
#queue_front(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Pushes a request to the front of the queue, to be performed by the hydra. Also sets hydra on request
49 50 51 52 |
# File 'lib/typhoeus/hydra/queueable.rb', line 49 def queue_front(request) request.hydra = self queued_requests.unshift request end |
#queued_requests ⇒ Array<Typhoeus::Request>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the queued requests.
16 17 18 |
# File 'lib/typhoeus/hydra/queueable.rb', line 16 def queued_requests @queued_requests ||= [] end |