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.

Since:

  • 0.5.0

API:

  • private

Instance Method Summary collapse

Instance Method Details

#abortObject

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.

Examples:

Abort hydra.

hydra.abort

Since:

  • 0.5.0

API:

  • private



27
28
29
# File 'lib/typhoeus/hydra/queueable.rb', line 27

def abort
  queued_requests.clear
end

#dequeueObject

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.

Examples:

Dequeue request.

hydra.dequeue

Since:

  • 0.6.4

API:

  • private



62
63
64
# File 'lib/typhoeus/hydra/queueable.rb', line 62

def dequeue
  add(queued_requests.shift) unless queued_requests.empty?
end

#dequeue_manyObject

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.

Examples:

Dequeue requests.

hydra.dequeue_many

Since:

  • 0.6.8

API:

  • private



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.

Examples:

Queue request.

hydra.queue(request)

Since:

  • 0.5.0

API:

  • private



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

Examples:

Queue reques.

hydra.queue_front(request)

Since:

  • 0.5.0

API:

  • private



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_requestsArray<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.

Examples:

Return queued requests.

hydra.queued_requests

Returns:

  • The queued requests.

Since:

  • 0.5.0

API:

  • private



16
17
18
# File 'lib/typhoeus/hydra/queueable.rb', line 16

def queued_requests
  @queued_requests ||= []
end