Class: Protobuf::Rpc::Connectors::Zmq

Inherits:
Base
  • Object
show all
Includes:
Logger::LogMethods, Common
Defined in:
lib/protobuf/rpc/connectors/zmq.rb

Constant Summary collapse

RequestTimeout =
Class.new(RuntimeError)
CLIENT_RETRIES =

Class Constants

(ENV['PB_CLIENT_RETRIES'] || 3)

Instance Attribute Summary

Attributes included from Common

#error

Attributes inherited from Base

#complete_cb, #failure_cb, #options, #success_cb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger::LogMethods

included, #log_exception, #sign_message

Methods included from Common

#any_callbacks?, #complete, #data_callback, #fail, #initialize_stats, #parse_response, #post_init, #request_bytes, #request_caller, #setup_connection, #succeed, #timeout_wrap, #validate_request_type!, #verify_callbacks, #verify_options!

Methods inherited from Base

#first_alive_load_balance?, #initialize, #ping_port, #ping_port_enabled?

Constructor Details

This class inherits a constructor from Protobuf::Rpc::Connectors::Base

Class Method Details

.zmq_contextObject

Class Methods



27
28
29
30
31
32
33
# File 'lib/protobuf/rpc/connectors/zmq.rb', line 27

def self.zmq_context
  @zmq_contexts ||= Hash.new { |hash, key|
    hash[key] = ZMQ::Context.new
  }

  @zmq_contexts[Process.pid]
end

Instance Method Details

#log_signatureObject



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

def log_signature
  @_log_signature ||= "[client-#{self.class}]"
end

#send_requestObject

Start the request/response cycle. We implement the Lazy Pirate req/reply reliability pattern as laid out in the ZMQ Guide, Chapter 4.



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

def send_request
  setup_connection
  send_request_with_lazy_pirate unless error?
end