Class: Protobuf::Rpc::Connectors::Base

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/protobuf/rpc/connectors/base.rb

Direct Known Subclasses

Socket, Zmq

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

initialize_logger, #log_exception, #log_signature, #logger, #sign_message

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



31
32
33
34
# File 'lib/protobuf/rpc/connectors/base.rb', line 31

def initialize(options)
  @options = DEFAULT_OPTIONS.merge(options)
  @stats = ::Protobuf::Rpc::Stat.new(:CLIENT)
end

Instance Attribute Details

#complete_cbObject

Returns the value of attribute complete_cb.



29
30
31
# File 'lib/protobuf/rpc/connectors/base.rb', line 29

def complete_cb
  @complete_cb
end

#failure_cbObject

Returns the value of attribute failure_cb.



29
30
31
# File 'lib/protobuf/rpc/connectors/base.rb', line 29

def failure_cb
  @failure_cb
end

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/protobuf/rpc/connectors/base.rb', line 28

def options
  @options
end

#success_cbObject

Returns the value of attribute success_cb.



29
30
31
# File 'lib/protobuf/rpc/connectors/base.rb', line 29

def success_cb
  @success_cb
end

Instance Method Details

#first_alive_load_balance?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/protobuf/rpc/connectors/base.rb', line 36

def first_alive_load_balance?
  ENV.key?("PB_FIRST_ALIVE_LOAD_BALANCE") ||
    options[:first_alive_load_balance]
end

#ping_portObject



45
46
47
# File 'lib/protobuf/rpc/connectors/base.rb', line 45

def ping_port
  @ping_port ||= ENV["PB_RPC_PING_PORT"]
end

#ping_port_enabled?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/protobuf/rpc/connectors/base.rb', line 49

def ping_port_enabled?
  ENV.key?("PB_RPC_PING_PORT")
end

#send_requestObject



41
42
43
# File 'lib/protobuf/rpc/connectors/base.rb', line 41

def send_request
  fail 'If you inherit a Connector from Base you must implement send_request'
end