Sha256: 4e922a27ce70e46b9d1d464ca805c7474bdaa692a9df9e768231fd3f778b0e79

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

module SubZero
  class Socket
    module Sender

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

        ::Timeout.timeout t do
          context do |c|
            socket c do |s|
              send_message s, request
              response = receive_message(s, request)
            end
          end
        end

        response
      rescue ::Timeout::Error
        raise SubZero::Socket::TimeoutError, "call timeout after #{t}ms"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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