class Liebre::Actor::RPC::Client::Core

Constants

EXPIRE_INTERVAL
OPTS

Attributes

client[R]
context[R]
pending[R]
resources[R]
task[R]

Public Class Methods

new(client, resources, context, pending, task) click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 10
def initialize client, resources, context, pending, task
  @client    = client
  @resources = resources
  @context   = context
  @pending   = pending
  @task      = task
end

Public Instance Methods

clean() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 50
def clean
  request_exchange.delete
  response_queue.delete
end
expire() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 46
def expire
  pending.expire()
end
reply(meta, response) click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 42
def reply meta, response
  pending.finish(meta.correlation_id, response)
end
request(payload, opts, timeout) click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 32
def request payload, opts, timeout
  r = pending.add(timeout) do |correlation_id|
    opts = opts.merge :reply_to       => response_queue.name,
                      :correlation_id => correlation_id

    request_exchange.publish(payload, opts)
    context.logger.info("request pending - correlation_id: #{correlation_id}")
  end
end
start() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 18
def start
  response_queue.subscribe(OPTS) do |_info, meta, payload|
    client.reply(meta, payload)
  end
  request_exchange

  task.every(EXPIRE_INTERVAL) { client.expire }
end
stop() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 27
def stop
  task.cancel_all
  chan.close
end

Private Instance Methods

chan() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 65
def chan
  context.chan
end
request_exchange() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 61
def request_exchange
  resources.request_exchange
end
response_queue() click to toggle source
# File lib/liebre/actor/rpc/client/core.rb, line 57
def response_queue
  resources.response_queue
end