Module: Thrift::Client
- Defined in:
- lib/thrift/client.rb
Instance Method Summary collapse
- #handle_exception(mtype) ⇒ Object
- #initialize(iprot, oprot = nil) ⇒ Object
- #receive_message(result_klass) ⇒ Object
- #receive_message_begin ⇒ Object
- #reply_seqid(rseqid) ⇒ Object
- #send_message(name, args_class, args = {}) ⇒ Object
- #send_message_args(args_class, args) ⇒ Object
- #send_oneway_message(name, args_class, args = {}) ⇒ Object
Instance Method Details
#handle_exception(mtype) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/thrift/client.rb', line 70 def handle_exception(mtype) if mtype == MessageTypes::EXCEPTION x = ApplicationException.new x.read(@iprot) @iprot. raise x end end |
#initialize(iprot, oprot = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/thrift/client.rb', line 22 def initialize(iprot, oprot=nil) @iprot = iprot @oprot = oprot || iprot @seqid = 0 end |
#receive_message(result_klass) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/thrift/client.rb', line 63 def (result_klass) result = result_klass.new result.read(@iprot) @iprot. result end |
#receive_message_begin ⇒ Object
53 54 55 56 |
# File 'lib/thrift/client.rb', line 53 def () fname, mtype, rseqid = @iprot. [fname, mtype, rseqid] end |
#reply_seqid(rseqid) ⇒ Object
58 59 60 61 |
# File 'lib/thrift/client.rb', line 58 def reply_seqid(rseqid) result = (rseqid==@seqid)?true:false result end |
#send_message(name, args_class, args = {}) ⇒ Object
28 29 30 31 |
# File 'lib/thrift/client.rb', line 28 def (name, args_class, args = {}) @oprot.(name, MessageTypes::CALL, @seqid) (args_class, args) end |
#send_message_args(args_class, args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/thrift/client.rb', line 38 def (args_class, args) 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. @oprot.trans.flush end |
#send_oneway_message(name, args_class, args = {}) ⇒ Object
33 34 35 36 |
# File 'lib/thrift/client.rb', line 33 def (name, args_class, args = {}) @oprot.(name, MessageTypes::ONEWAY, @seqid) (args_class, args) end |