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

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


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


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

def dequeue
  add(queued_requests.shift) unless queued_requests.empty?
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


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


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

Since:

  • 0.5.0


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

def queued_requests
  @queued_requests ||= []
end