module Thrift::Client
Public Class Methods
new(iprot, oprot=nil)
click to toggle source
# File lib/thrift/client.rb 22 def initialize(iprot, oprot=nil) 23 @iprot = iprot 24 @oprot = oprot || iprot 25 @seqid = 0 26 end
Public Instance Methods
handle_exception(mtype)
click to toggle source
# File lib/thrift/client.rb 62 def handle_exception(mtype) 63 if mtype == MessageTypes::EXCEPTION 64 x = ApplicationException.new 65 x.read(@iprot) 66 @iprot.read_message_end 67 raise x 68 end 69 end
receive_message(result_klass)
click to toggle source
# File lib/thrift/client.rb 53 def receive_message(result_klass) 54 fname, mtype, rseqid = @iprot.read_message_begin 55 handle_exception(mtype) 56 result = result_klass.new 57 result.read(@iprot) 58 @iprot.read_message_end 59 result 60 end
send_message(name, args_class, args = {})
click to toggle source
# File lib/thrift/client.rb 28 def send_message(name, args_class, args = {}) 29 @oprot.write_message_begin(name, MessageTypes::CALL, @seqid) 30 send_message_args(args_class, args) 31 end
send_message_args(args_class, args)
click to toggle source
# File lib/thrift/client.rb 38 def send_message_args(args_class, args) 39 data = args_class.new 40 args.each do |k, v| 41 data.send("#{k.to_s}=", v) 42 end 43 begin 44 data.write(@oprot) 45 rescue StandardError => e 46 @oprot.trans.close 47 raise e 48 end 49 @oprot.write_message_end 50 @oprot.trans.flush 51 end
send_oneway_message(name, args_class, args = {})
click to toggle source
# File lib/thrift/client.rb 33 def send_oneway_message(name, args_class, args = {}) 34 @oprot.write_message_begin(name, MessageTypes::ONEWAY, @seqid) 35 send_message_args(args_class, args) 36 end