Sha256: 3c43c9835b7cd52a82a8dd1f59b49dcac8f04a7804de5b993e8393ec67288936

Contents?: true

Size: 1.17 KB

Versions: 25

Compression:

Stored size: 1.17 KB

Contents

require 'resolv'

module Protobuf
  module Rpc
    module Zmq

      ADDRESS_MATCH = /\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/.freeze
      WORKER_READY_MESSAGE = "\1"
      CHECK_AVAILABLE_MESSAGE = "\3"
      NO_WORKERS_AVAILABLE = "\4"
      WORKERS_AVAILABLE = "\5"
      EMPTY_STRING = ""

      module Util
        include ::Protobuf::Logging

        def self.included(base)
          base.extend(::Protobuf::Rpc::Zmq::Util)
        end

        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

        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

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
protobuf-3.6.12 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.11 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.10 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.7.0.pre2 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.9 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.7.0.pre1 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.7.0.pre0 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.7 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.6 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.2 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.1 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.6.0 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.5 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.4 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.3 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.2 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.1 lib/protobuf/rpc/servers/zmq/util.rb
prepor-protobuf-3.5.1 lib/protobuf/rpc/servers/zmq/util.rb
prepor-protobuf-3.5.0 lib/protobuf/rpc/servers/zmq/util.rb
protobuf-3.5.0 lib/protobuf/rpc/servers/zmq/util.rb