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.



537
538
539
540
541
# File 'lib/avro/ipc.rb', line 537

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.



536
537
538
# File 'lib/avro/ipc.rb', line 536

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



536
537
538
# File 'lib/avro/ipc.rb', line 536

def port
  @port
end

#remote_nameObject (readonly)

Returns the value of attribute remote_name.



536
537
538
# File 'lib/avro/ipc.rb', line 536

def remote_name
  @remote_name
end

Instance Method Details

#transceive(message) ⇒ Object



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

def transceive(message)
  writer = FramedWriter.new(StringIO.new)
  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