| Class | ThriftClient::Simple::ThriftService |
| In: |
lib/thrift_client/simple.rb
lib/thrift_client/simple.rb |
| Parent: | Object |
# File lib/thrift_client/simple.rb, line 240
240: def self._arg_structs
241: @_arg_structs = {} if @_arg_structs.nil?
242: @_arg_structs
243: end
# File lib/thrift_client/simple.rb, line 240
240: def self._arg_structs
241: @_arg_structs = {} if @_arg_structs.nil?
242: @_arg_structs
243: end
# File lib/thrift_client/simple.rb, line 245
245: def self.thrift_method(name, rtype, *args)
246: arg_struct = ThriftClient::Simple.make_struct("Args__#{self.name}__#{name}", *args)
247: rv_struct = ThriftClient::Simple.make_struct("Retval__#{self.name}__#{name}", ThriftClient::Simple::Field.new(:rv, rtype, 0))
248: _arg_structs[name.to_sym] = [ arg_struct, rv_struct ]
249:
250: arg_names = args.map { |a| a.name.to_s }.join(", ")
251: class_eval "def #{name}(#{arg_names}); _proxy(:#{name}#{args.size > 0 ? ', ' : ''}#{arg_names}); end"
252: end
# File lib/thrift_client/simple.rb, line 245
245: def self.thrift_method(name, rtype, *args)
246: arg_struct = ThriftClient::Simple.make_struct("Args__#{self.name}__#{name}", *args)
247: rv_struct = ThriftClient::Simple.make_struct("Retval__#{self.name}__#{name}", ThriftClient::Simple::Field.new(:rv, rtype, 0))
248: _arg_structs[name.to_sym] = [ arg_struct, rv_struct ]
249:
250: arg_names = args.map { |a| a.name.to_s }.join(", ")
251: class_eval "def #{name}(#{arg_names}); _proxy(:#{name}#{args.size > 0 ? ', ' : ''}#{arg_names}); end"
252: end
# File lib/thrift_client/simple.rb, line 254
254: def _proxy(method_name, *args)
255: cls = self.class.ancestors.find { |cls| cls.respond_to?(:_arg_structs) and cls._arg_structs[method_name.to_sym] }
256: arg_class, rv_class = cls._arg_structs[method_name.to_sym]
257: arg_struct = arg_class.new(*args)
258: @sock.write(ThriftClient::Simple.pack_request(method_name, arg_struct))
259: rv = ThriftClient::Simple.read_response(@sock, rv_class)
260: rv[2]
261: end
# File lib/thrift_client/simple.rb, line 254
254: def _proxy(method_name, *args)
255: cls = self.class.ancestors.find { |cls| cls.respond_to?(:_arg_structs) and cls._arg_structs[method_name.to_sym] }
256: arg_class, rv_class = cls._arg_structs[method_name.to_sym]
257: arg_struct = arg_class.new(*args)
258: @sock.write(ThriftClient::Simple.pack_request(method_name, arg_struct))
259: rv = ThriftClient::Simple.read_response(@sock, rv_class)
260: rv[2]
261: end