Repository: thrift Updated Branches: refs/heads/master 1ff4a97a4 -> 05d64b4e3
THRIFT-2707: rb - support for oneway messages fixed Client: Ruby Library, Ruby Compiler Patch: Konrad Grochowski now oneway method calls will use proper message type This closes #217 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/05d64b4e Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/05d64b4e Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/05d64b4e Branch: refs/heads/master Commit: 05d64b4e3bcac81b31b89a2db2255edd72b783a8 Parents: 1ff4a97 Author: Konrad Grochowski <[email protected]> Authored: Tue Sep 16 19:39:19 2014 +0200 Committer: Konrad Grochowski <[email protected]> Committed: Mon Sep 29 22:08:58 2014 +0200 ---------------------------------------------------------------------- compiler/cpp/src/generate/t_rb_generator.cc | 3 ++- lib/rb/lib/thrift/client.rb | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/05d64b4e/compiler/cpp/src/generate/t_rb_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index dec53dd..3cfc0b1 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -889,8 +889,9 @@ void t_rb_generator::generate_service_client(t_service* tservice) { f_service_.indent_up(); std::string argsname = capitalize((*f_iter)->get_name() + "_args"); + std::string messageSendProc = (*f_iter)->is_oneway() ? "send_oneway_message" : "send_message"; - f_service_.indent() << "send_message('" << funname << "', " << argsname; + f_service_.indent() << messageSendProc << "('" << funname << "', " << argsname; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << ", :" << (*fld_iter)->get_name() << " => " << (*fld_iter)->get_name(); http://git-wip-us.apache.org/repos/asf/thrift/blob/05d64b4e/lib/rb/lib/thrift/client.rb ---------------------------------------------------------------------- diff --git a/lib/rb/lib/thrift/client.rb b/lib/rb/lib/thrift/client.rb index 5b30f01..64ef059 100644 --- a/lib/rb/lib/thrift/client.rb +++ b/lib/rb/lib/thrift/client.rb @@ -1,4 +1,4 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -6,16 +6,16 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# +# module Thrift module Client @@ -27,6 +27,15 @@ module Thrift def send_message(name, args_class, args = {}) @oprot.write_message_begin(name, MessageTypes::CALL, @seqid) + send_message_args(args_class, args) + end + + def send_oneway_message(name, args_class, args = {}) + @oprot.write_message_begin(name, MessageTypes::ONEWAY, @seqid) + send_message_args(args_class, args) + end + + def send_message_args(args_class, args) data = args_class.new args.each do |k, v| data.send("#{k.to_s}=", v)
