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.



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

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.



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

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#remote_nameObject (readonly)

Returns the value of attribute remote_name.



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

def remote_name
  @remote_name
end

Instance Method Details

#transceive(message) ⇒ Object



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

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