Sha256: fe2a3f768a87c3473dd3ecedd2656978c9b6ad5a3e983384bb66441d7653ac3f

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

module SubZero
  class Socket
    module Sender

      def call request
        response = nil
        t = request.options.fetch(:timeout, 1000) / 1000.0

          context do |c|
            socket c do |s|
              begin
                ::Timeout.timeout t do
                  send_message s, request
                  response = receive_message(s, request)
                end
              rescue ::Timeout::Error
                raise SubZero::Socket::TimeoutError, "call timeout after #{t}ms"
              end
            end
          end

        response
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sub_zero-0.0.8 lib/sub_zero/socket/sender.rb