Author: dreiss
Date: Thu Apr 2 19:22:31 2009
New Revision: 761389
URL: http://svn.apache.org/viewvc?rev=761389&view=rev
Log:
THRIFT-388. Create a "ONEWAY" message type that is an alias for "CALL"
Pave the way for a new message type for oneway function calls.
For now, just define the constant in all languages and make
server implementations treat it the same way as a normal call.
Only C++ and Erlang currently check the message type (on the
server side).
There is a little bit of redundancy in the Erlang code, but
the alternative is a bit gross, and this split-up will be
necessary eventually when we start handling one-way calls
differently.
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
incubator/thrift/trunk/lib/cocoa/src/protocol/TProtocol.h
incubator/thrift/trunk/lib/cpp/src/protocol/TProtocol.h
incubator/thrift/trunk/lib/csharp/src/Protocol/TMessageType.cs
incubator/thrift/trunk/lib/erl/include/thrift_constants.hrl
incubator/thrift/trunk/lib/erl/src/thrift_processor.erl
incubator/thrift/trunk/lib/hs/src/Thrift.hs
incubator/thrift/trunk/lib/java/src/org/apache/thrift/protocol/TMessageType.java
incubator/thrift/trunk/lib/ocaml/src/Thrift.ml
incubator/thrift/trunk/lib/perl/lib/Thrift.pm
incubator/thrift/trunk/lib/php/src/Thrift.php
incubator/thrift/trunk/lib/py/src/Thrift.py
incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc Thu Apr
2 19:22:31 2009
@@ -1909,7 +1909,7 @@
endl <<
indent() << "iprot->readMessageBegin(fname, mtype, seqid);" << endl <<
endl <<
- indent() << "if (mtype != apache::thrift::protocol::T_CALL) {" << endl <<
+ indent() << "if (mtype != apache::thrift::protocol::T_CALL && mtype !=
apache::thrift::protocol::T_ONEWAY) {" << endl <<
indent() << " iprot->skip(apache::thrift::protocol::T_STRUCT);" << endl <<
indent() << " iprot->readMessageEnd();" << endl <<
indent() << " iprot->getTransport()->readEnd();" << endl <<
Modified: incubator/thrift/trunk/lib/cocoa/src/protocol/TProtocol.h
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cocoa/src/protocol/TProtocol.h?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cocoa/src/protocol/TProtocol.h (original)
+++ incubator/thrift/trunk/lib/cocoa/src/protocol/TProtocol.h Thu Apr 2
19:22:31 2009
@@ -25,7 +25,8 @@
enum {
TMessageType_CALL = 1,
TMessageType_REPLY = 2,
- TMessageType_EXCEPTION = 3
+ TMessageType_EXCEPTION = 3,
+ TMessageType_ONEWAY = 4
};
enum {
Modified: incubator/thrift/trunk/lib/cpp/src/protocol/TProtocol.h
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cpp/src/protocol/TProtocol.h?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cpp/src/protocol/TProtocol.h (original)
+++ incubator/thrift/trunk/lib/cpp/src/protocol/TProtocol.h Thu Apr 2 19:22:31
2009
@@ -97,7 +97,8 @@
enum TMessageType {
T_CALL = 1,
T_REPLY = 2,
- T_EXCEPTION = 3
+ T_EXCEPTION = 3,
+ T_ONEWAY = 4
};
/**
Modified: incubator/thrift/trunk/lib/csharp/src/Protocol/TMessageType.cs
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/csharp/src/Protocol/TMessageType.cs?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/csharp/src/Protocol/TMessageType.cs (original)
+++ incubator/thrift/trunk/lib/csharp/src/Protocol/TMessageType.cs Thu Apr 2
19:22:31 2009
@@ -25,6 +25,7 @@
{
Call = 1,
Reply = 2,
- Exception = 3
+ Exception = 3,
+ Oneway = 4
}
}
Modified: incubator/thrift/trunk/lib/erl/include/thrift_constants.hrl
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/include/thrift_constants.hrl?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/erl/include/thrift_constants.hrl (original)
+++ incubator/thrift/trunk/lib/erl/include/thrift_constants.hrl Thu Apr 2
19:22:31 2009
@@ -36,6 +36,7 @@
-define(tMessageType_CALL, 1).
-define(tMessageType_REPLY, 2).
-define(tMessageType_EXCEPTION, 3).
+-define(tMessageType_ONEWAY, 4).
% TApplicationException
-define(TApplicationException_Structure,
Modified: incubator/thrift/trunk/lib/erl/src/thrift_processor.erl
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/src/thrift_processor.erl?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/erl/src/thrift_processor.erl (original)
+++ incubator/thrift/trunk/lib/erl/src/thrift_processor.erl Thu Apr 2 19:22:31
2009
@@ -40,6 +40,10 @@
type = ?tMessageType_CALL} ->
ok = handle_function(State, list_to_atom(Function)),
loop(State);
+ #protocol_message_begin{name = Function,
+ type = ?tMessageType_ONEWAY} ->
+ ok = handle_function(State, list_to_atom(Function)),
+ loop(State);
{error, timeout} ->
thrift_protocol:close_transport(OProto),
ok;
Modified: incubator/thrift/trunk/lib/hs/src/Thrift.hs
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/hs/src/Thrift.hs?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/hs/src/Thrift.hs (original)
+++ incubator/thrift/trunk/lib/hs/src/Thrift.hs Thu Apr 2 19:22:31 2009
@@ -118,6 +118,7 @@
data Message_type = M_CALL
| M_REPLY
| M_EXCEPTION
+ | M_ONEWAY
| M_UNKNOWN
deriving Eq
instance Enum Message_type where
@@ -126,12 +127,14 @@
M_CALL -> 1
M_REPLY -> 2
M_EXCEPTION -> 3
+ M_ONEWAY -> 4
M_UNKNOWN -> -1
toEnum t = case t of
1 -> M_CALL
2 -> M_REPLY
3 -> M_EXCEPTION
+ 4 -> M_ONEWAY
_ -> M_UNKNOWN
Modified:
incubator/thrift/trunk/lib/java/src/org/apache/thrift/protocol/TMessageType.java
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/java/src/org/apache/thrift/protocol/TMessageType.java?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
---
incubator/thrift/trunk/lib/java/src/org/apache/thrift/protocol/TMessageType.java
(original)
+++
incubator/thrift/trunk/lib/java/src/org/apache/thrift/protocol/TMessageType.java
Thu Apr 2 19:22:31 2009
@@ -27,4 +27,5 @@
public static final byte CALL = 1;
public static final byte REPLY = 2;
public static final byte EXCEPTION = 3;
+ public static final byte ONEWAY = 4;
}
Modified: incubator/thrift/trunk/lib/ocaml/src/Thrift.ml
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/ocaml/src/Thrift.ml?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/ocaml/src/Thrift.ml (original)
+++ incubator/thrift/trunk/lib/ocaml/src/Thrift.ml Thu Apr 2 19:22:31 2009
@@ -141,16 +141,19 @@
| CALL
| REPLY
| EXCEPTION
+ | ONEWAY
let message_type_to_i = function
| CALL -> 1
| REPLY -> 2
| EXCEPTION -> 3
+ | ONEWAY -> 4
let message_type_of_i = function
| 1 -> CALL
| 2 -> REPLY
| 3 -> EXCEPTION
+ | 4 -> ONEWAY
| _ -> raise Thrift_error
class virtual t (trans: Transport.t) =
Modified: incubator/thrift/trunk/lib/perl/lib/Thrift.pm
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/perl/lib/Thrift.pm?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/perl/lib/Thrift.pm (original)
+++ incubator/thrift/trunk/lib/perl/lib/Thrift.pm Thu Apr 2 19:22:31 2009
@@ -53,6 +53,7 @@
use constant CALL => 1;
use constant REPLY => 2;
use constant EXCEPTION => 3;
+use constant ONEWAY => 4;
1;
package Thrift::TException;
Modified: incubator/thrift/trunk/lib/php/src/Thrift.php
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/Thrift.php?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/php/src/Thrift.php (original)
+++ incubator/thrift/trunk/lib/php/src/Thrift.php Thu Apr 2 19:22:31 2009
@@ -51,6 +51,7 @@
const CALL = 1;
const REPLY = 2;
const EXCEPTION = 3;
+ const ONEWAY = 4;
}
/**
Modified: incubator/thrift/trunk/lib/py/src/Thrift.py
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/py/src/Thrift.py?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/py/src/Thrift.py (original)
+++ incubator/thrift/trunk/lib/py/src/Thrift.py Thu Apr 2 19:22:31 2009
@@ -40,6 +40,7 @@
CALL = 1
REPLY = 2
EXCEPTION = 3
+ ONEWAY = 4
class TProcessor:
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/types.rb?rev=761389&r1=761388&r2=761389&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/types.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/types.rb Thu Apr 2 19:22:31 2009
@@ -94,6 +94,7 @@
CALL = 1
REPLY = 2
EXCEPTION = 3
+ ONEWAY = 4
end
end