Module: Protobuf::Rpc::Zmq::Util

Includes:
Logging
Included in:
Broker, Server, Worker
Defined in:
lib/protobuf/rpc/servers/zmq/util.rb

Instance Method Summary collapse

Methods included from Logging

initialize_logger, #log_exception, #logger, #sign_message

Instance Method Details

#log_signatureObject



31
32
33
34
35
36
37
38
# File 'lib/protobuf/rpc/servers/zmq/util.rb', line 31

def log_signature
  unless @_log_signature
    name = (self.class == Class ? self.name : self.class.name)
    @_log_signature = "[server-#{name}-#{object_id}]"
  end

  @_log_signature
end

#resolve_ip(hostname) ⇒ Object



40
41
42
43
44
# File 'lib/protobuf/rpc/servers/zmq/util.rb', line 40

def resolve_ip(hostname)
  ::Resolv.getaddresses(hostname).find do |address|
    address =~ ADDRESS_MATCH
  end
end

#zmq_error_check(return_code, source = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/protobuf/rpc/servers/zmq/util.rb', line 21

def zmq_error_check(return_code, source = nil)
  return if ::ZMQ::Util.resultcode_ok?(return_code)

  fail <<-ERROR
  Last ZMQ API call #{source ? "to #{source}" : ''} failed with "#{::ZMQ::Util.error_string}".

  #{caller(1).join($INPUT_RECORD_SEPARATOR)}
  ERROR
end