Class: Wamp::Worker::Proxy::Backgrounder

Inherits:
Requestor show all
Defined in:
lib/wamp/worker/proxy/backgrounder.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #queue, #ticker, #uuid

Instance Method Summary collapse

Methods inherited from Requestor

#call, #publish

Methods inherited from Base

#background_res_queue, #command_req_queue, #unique_command_resp_queue

Constructor Details

#initialize(name, handle, uuid: nil) ⇒ Backgrounder

Constructor



12
13
14
15
# File 'lib/wamp/worker/proxy/backgrounder.rb', line 12

def initialize(name, handle, uuid: nil)
  super name, uuid: uuid
  @handle = handle
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



8
9
10
# File 'lib/wamp/worker/proxy/backgrounder.rb', line 8

def handle
  @handle
end

Instance Method Details

#yield(request, result, options = {}, check_defer = false) ⇒ Object

Returns the response to the dispatcher

Parameters:

  • request (Int)
    • The ID of the request

  • result (CallResult, CallError)
    • The result or error for us to serialize

  • options (Hash) (defaults to: {})
    • Options for the yield

  • check_defer (Bool) (defaults to: false)
    • ‘true’ is this is linked to a defer call



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/wamp/worker/proxy/backgrounder.rb', line 23

def yield(request, result, options={}, check_defer=false)

  # Create the response object
  result = Wamp::Client::Response::CallResult.ensure(result, allow_error: true)

  # Create the params
  params = { request: request, result: result.to_hash, options: options, check_defer: check_defer }

  # Push to the worker who requested the result
  self.queue.push self.handle, :yield, params
end