Class: Delayed::WorkQueue::ParentProcess::Client
- Inherits:
-
Object
- Object
- Delayed::WorkQueue::ParentProcess::Client
- Defined in:
- lib/delayed/work_queue/parent_process.rb
Instance Attribute Summary collapse
-
#addrinfo ⇒ Object
readonly
Returns the value of attribute addrinfo.
Instance Method Summary collapse
- #get_and_lock_next_available(name, queue_name, min_priority, max_priority) ⇒ Object
-
#initialize(addrinfo) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(addrinfo) ⇒ Client
Returns a new instance of Client.
57 58 59 |
# File 'lib/delayed/work_queue/parent_process.rb', line 57 def initialize(addrinfo) @addrinfo = addrinfo end |
Instance Attribute Details
#addrinfo ⇒ Object (readonly)
Returns the value of attribute addrinfo.
55 56 57 |
# File 'lib/delayed/work_queue/parent_process.rb', line 55 def addrinfo @addrinfo end |
Instance Method Details
#get_and_lock_next_available(name, queue_name, min_priority, max_priority) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/delayed/work_queue/parent_process.rb', line 61 def get_and_lock_next_available(name, queue_name, min_priority, max_priority) @socket ||= @addrinfo.connect Marshal.dump([name, queue_name, min_priority, max_priority], @socket) response = Marshal.load(@socket) unless response.nil? || (response.is_a?(Delayed::Job) && response.locked_by == name) raise(ProtocolError, "response is not a locked job: #{response.inspect}") end response rescue SystemCallError, IOError # The work queue process died. Return nil to signal the worker # process should sleep as if no job was found, and then retry. @socket = nil nil end |