Module: Thrift::Client

Defined in:
lib/thrift_client/thrift.rb,
lib/thrift_client/multiplexed_client.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



3
4
5
# File 'lib/thrift_client/thrift.rb', line 3

def close
  @iprot.trans.close
end

#initialize(service, iprot, oprot = nil) ⇒ Object



5
6
7
8
# File 'lib/thrift_client/multiplexed_client.rb', line 5

def initialize(service, iprot, oprot=nil)
  old_initialize(iprot, oprot)
  @service = service
end

#old_initializeObject



3
# File 'lib/thrift_client/multiplexed_client.rb', line 3

alias :old_initialize :initialize

#openObject



7
8
9
# File 'lib/thrift_client/thrift.rb', line 7

def open
  @iprot.trans.open
end

#open?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/thrift_client/thrift.rb', line 11

def open?
  @iprot.trans.open?
end

#send_message(name, args_class, args = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/thrift_client/multiplexed_client.rb', line 10

def send_message(name, args_class, args = {})
  @oprot.write_message_begin(@service + ':' + name, MessageTypes::CALL, @seqid)
  data = args_class.new
  args.each do |k, v|
    data.send("#{k.to_s}=", v)
  end
  begin
    data.write(@oprot)
  rescue StandardError => e
    @oprot.trans.close
    raise e
  end
  @oprot.write_message_end
  @oprot.trans.flush
end