Class: Cuboid::RPC::Client::Base

Inherits:
Toq::Client
  • Object
show all
Defined in:
lib/cuboid/rpc/client/base.rb

Overview

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, token = nil, options = nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • url (String)

    Server URL in ‘address:port` format.

  • token (String) (defaults to: nil)

    Optional authentication token.

  • options (Hash) (defaults to: nil)

Options Hash (options):

  • :connection_pool_size (Integer)
  • :max_retries (Integer)
  • :ssl_ca (Integer)
  • :ssl_pkey (Integer)
  • :ssl_cert (Integer)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cuboid/rpc/client/base.rb', line 22

def initialize( url, token = nil, options = nil )
    @url = url

    socket, host, port = nil
    if url.include? ':'
        host, port = url.split( ':' )
    else
        socket = url
    end

    @address = host
    @port    = port

    # If given nil use the global defaults.
    options ||= Options.rpc.to_client_options

    super( options.merge(
        serializer: Serializer,
        host:       host,
        port:       port.to_i,
        socket:     socket,
        token:      token
    ))
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/cuboid/rpc/client/base.rb', line 10

def url
  @url
end

Instance Method Details

#addressObject



47
48
49
# File 'lib/cuboid/rpc/client/base.rb', line 47

def address
    @address
end

#portObject



51
52
53
# File 'lib/cuboid/rpc/client/base.rb', line 51

def port
    @port
end