Class: EMRPC::Client
- Inherits:
-
Object
- Object
- EMRPC::Client
- Defined in:
- lib/emrpc/client.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
5 sec.
5
- DEFAULT_PROTOCOL =
Default EventMachine connection protocol
:ClientProtocol
- DEFAULT_CONNECTIONS =
10 threads can operate concurrently, others will wait.
10
Instance Attribute Summary collapse
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Class Method Summary collapse
-
.new(*args, &blk) ⇒ Object
Create a regular object holding configuration, but returns a method proxy.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 22 23 24 25 |
# File 'lib/emrpc/client.rb', line 17 def initialize( = {}) @host = [:host] or raise ":host required!" @port = [:port] or raise ":port required!" @timeout = [:timeout] || DEFAULT_TIMEOUT @protocol = [:protocol] || DEFAULT_PROTOCOL @connections = Array.new(.delete(:connections) || DEFAULT_CONNECTIONS) do ClientConnection.new() end end |
Instance Attribute Details
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
7 8 9 |
# File 'lib/emrpc/client.rb', line 7 def connections @connections end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/emrpc/client.rb', line 7 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/emrpc/client.rb', line 7 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
7 8 9 |
# File 'lib/emrpc/client.rb', line 7 def protocol @protocol end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/emrpc/client.rb', line 7 def timeout @timeout end |
Class Method Details
.new(*args, &blk) ⇒ Object
Create a regular object holding configuration, but returns a method proxy.
10 11 12 13 14 15 |
# File 'lib/emrpc/client.rb', line 10 def self.new(*args, &blk) client = super(*args) backend = MultithreadedClient.new(:backends => client.connections, :timeout => client.timeout) MethodProxy.new(backend) end |