Class: Cuboid::RPC::Client::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/cuboid/rpc/client/agent.rb

Overview

RPC Agent client

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = nil) ⇒ Agent

Returns a new instance of Agent.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cuboid/rpc/client/agent.rb', line 17

def initialize( url, options = nil )
    @client = Base.new( url, nil, options )
    @node   = Toq::Proxy.new( @client, 'node' )

    Cuboid::Application.application.agent_services.keys.each do |name|
        self.class.send( :attr_reader, name.to_sym )

        instance_variable_set(
          "@#{name}".to_sym,
          Toq::Proxy.new( @client, name )
        )
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object (private)

Used to provide the illusion of locality for remote methods



50
51
52
# File 'lib/cuboid/rpc/client/agent.rb', line 50

def method_missing( sym, *args, &block )
    @client.call( "agent.#{sym.to_s}", *args, &block )
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



15
16
17
# File 'lib/cuboid/rpc/client/agent.rb', line 15

def node
  @node
end

#pidObject

Not always available, set by the parent.



13
14
15
# File 'lib/cuboid/rpc/client/agent.rb', line 13

def pid
  @pid
end

Instance Method Details

#addressObject



35
36
37
# File 'lib/cuboid/rpc/client/agent.rb', line 35

def address
    @client.address
end

#closeObject



43
44
45
# File 'lib/cuboid/rpc/client/agent.rb', line 43

def close
    @client.close
end

#portObject



39
40
41
# File 'lib/cuboid/rpc/client/agent.rb', line 39

def port
    @client.port
end

#urlObject



31
32
33
# File 'lib/cuboid/rpc/client/agent.rb', line 31

def url
    @client.url
end