Class: JRPC::TcpClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- JRPC::TcpClient
- Defined in:
- lib/jrpc/tcp_client.rb
Constant Summary collapse
- MAX_LOGGED_MESSAGE_LENGTH =
255
Constants inherited from BaseClient
BaseClient::ID_CHARACTERS, BaseClient::REQUEST_TYPES
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Attributes inherited from BaseClient
Instance Method Summary collapse
-
#initialize(uri, options = {}) ⇒ TcpClient
constructor
A new instance of TcpClient.
Methods inherited from BaseClient
connect, #invoke_notification, #invoke_request, #method_missing, #perform_request
Constructor Details
#initialize(uri, options = {}) ⇒ TcpClient
Returns a new instance of TcpClient.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jrpc/tcp_client.rb', line 12 def initialize(uri, = {}) super @logger = @options.delete(:logger) || Logger.new($null) @namespace = @options.delete(:namespace).to_s timeout = @options.fetch(:timeout, 5) connect_timeout = @options.fetch(:connect_timeout, timeout) read_timeout = @options.fetch(:read_timeout, timeout) write_timeout = @options.fetch(:write_timeout, 60) # default 60 connect_retry_count = @options.fetch(:connect_retry_count, 10) # default 10 @close_after_sent = @options.fetch(:close_after_sent, false) @transport = JRPC::Transport::SocketTcp.new server: @uri, connect_retry_count: connect_retry_count, connect_timeout: connect_timeout, read_timeout: read_timeout, write_timeout: write_timeout begin @transport.connect rescue JRPC::Transport::SocketTcp::Error raise ConnectionError, "Can't connect to #{@uri}" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JRPC::BaseClient
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/jrpc/tcp_client.rb', line 7 def logger @logger end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/jrpc/tcp_client.rb', line 6 def namespace @namespace end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
6 7 8 |
# File 'lib/jrpc/tcp_client.rb', line 6 def transport @transport end |