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
53 def handle_exception(mtype)
54   if mtype == MessageTypes::EXCEPTION
55     x = ApplicationException.new
56     x.read(@iprot)
57     @iprot.read_message_end
58     raise x
59   end
60 end
receive_message(result_klass) click to toggle source
   # File lib/thrift/client.rb
44 def receive_message(result_klass)
45   fname, mtype, rseqid = @iprot.read_message_begin
46   handle_exception(mtype)
47   result = result_klass.new
48   result.read(@iprot)
49   @iprot.read_message_end
50   result
51 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   data = args_class.new
31   args.each do |k, v|
32     data.send("#{k.to_s}=", v)
33   end
34   begin
35     data.write(@oprot)
36   rescue StandardError => e
37     @oprot.trans.close
38     raise e
39   end
40   @oprot.write_message_end
41   @oprot.trans.flush
42 end