Class: Avro::IPC::HTTPTransceiver

Inherits:
Object
  • Object
show all
Defined in:
lib/avro/ipc.rb

Overview

Only works for clients. Sigh.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ HTTPTransceiver

Returns a new instance of HTTPTransceiver.



542
543
544
545
546
# File 'lib/avro/ipc.rb', line 542

def initialize(host, port)
  @host, @port = host, port
  @remote_name = "#{host}:#{port}"
  @conn = Net::HTTP.start host, port
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



541
542
543
# File 'lib/avro/ipc.rb', line 541

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



541
542
543
# File 'lib/avro/ipc.rb', line 541

def port
  @port
end

#remote_nameObject (readonly)

Returns the value of attribute remote_name.



541
542
543
# File 'lib/avro/ipc.rb', line 541

def remote_name
  @remote_name
end

Instance Method Details

#transceive(message) ⇒ Object



548
549
550
551
552
553
# File 'lib/avro/ipc.rb', line 548

def transceive(message)
  writer = FramedWriter.new(StringIO.new(String.new('', encoding: 'BINARY')))
  writer.write_framed_message(message)
  resp = @conn.post('/', writer.to_s, {'Content-Type' => 'avro/binary'})
  FramedReader.new(StringIO.new(resp.body)).read_framed_message
end