THRIFT-388. Create a "ONEWAY" message type that is an alias for "CALL"
authorDavid Reiss <dreiss@apache.org>
Thu, 2 Apr 2009 19:22:31 +0000 (19:22 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 2 Apr 2009 19:22:31 +0000 (19:22 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761389 13f79535-47bb-0310-9956-ffa450edef68

13 files changed:
compiler/cpp/src/generate/t_cpp_generator.cc
lib/cocoa/src/protocol/TProtocol.h
lib/cpp/src/protocol/TProtocol.h
lib/csharp/src/Protocol/TMessageType.cs
lib/erl/include/thrift_constants.hrl
lib/erl/src/thrift_processor.erl
lib/hs/src/Thrift.hs
lib/java/src/org/apache/thrift/protocol/TMessageType.java
lib/ocaml/src/Thrift.ml
lib/perl/lib/Thrift.pm
lib/php/src/Thrift.php
lib/py/src/Thrift.py
lib/rb/lib/thrift/types.rb

index 9d57269..00c813e 100644 (file)
@@ -1909,7 +1909,7 @@ void t_cpp_generator::generate_service_processor(t_service* tservice) {
     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 <<
index 126f5df..cc8cdb4 100644 (file)
@@ -25,7 +25,8 @@
 enum {
   TMessageType_CALL = 1,
   TMessageType_REPLY = 2,
-  TMessageType_EXCEPTION = 3
+  TMessageType_EXCEPTION = 3,
+  TMessageType_ONEWAY = 4
 };
 
 enum {
index 37d0801..0c513d1 100644 (file)
@@ -97,7 +97,8 @@ enum TType {
 enum TMessageType {
   T_CALL       = 1,
   T_REPLY      = 2,
-  T_EXCEPTION  = 3
+  T_EXCEPTION  = 3,
+  T_ONEWAY     = 4
 };
 
 /**
index 42a6a20..ab07cf6 100644 (file)
@@ -25,6 +25,7 @@ namespace Thrift.Protocol
        {
                Call = 1,
                Reply = 2,
-               Exception = 3
+               Exception = 3,
+               Oneway = 4
        }
 }
index 40c0c16..36eb49b 100644 (file)
@@ -36,6 +36,7 @@
 -define(tMessageType_CALL, 1).
 -define(tMessageType_REPLY, 2).
 -define(tMessageType_EXCEPTION, 3).
+-define(tMessageType_ONEWAY, 4).
 
 % TApplicationException
 -define(TApplicationException_Structure,
index 1adea67..e26fb33 100644 (file)
@@ -40,6 +40,10 @@ loop(State = #thrift_processor{in_protocol  = IProto,
                                 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;
index b3ce8a4..293edf1 100644 (file)
@@ -118,6 +118,7 @@ module Thrift (TransportExn(..),TransportExn_Type(..),TTransport(..), T_type(..)
   data Message_type = M_CALL
                     | M_REPLY
                     | M_EXCEPTION
+                    | M_ONEWAY
                     | M_UNKNOWN
                       deriving Eq
   instance Enum Message_type where
@@ -126,12 +127,14 @@ module Thrift (TransportExn(..),TransportExn_Type(..),TTransport(..), T_type(..)
                      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
 
 
index 714ea70..aa3f931 100644 (file)
@@ -27,4 +27,5 @@ public final class TMessageType {
   public static final byte CALL  = 1;
   public static final byte REPLY = 2;
   public static final byte EXCEPTION = 3;
+  public static final byte ONEWAY = 4;
 }
index 0d16470..8dc9afa 100644 (file)
@@ -141,16 +141,19 @@ struct
     | 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) =
index 2560df7..fe0f8e7 100644 (file)
@@ -53,6 +53,7 @@ package TMessageType;
 use constant CALL      => 1;
 use constant REPLY     => 2;
 use constant EXCEPTION => 3;
+use constant ONEWAY    => 4;
 1;
 
 package Thrift::TException;
index dd1e0d7..ef6ab8a 100644 (file)
@@ -51,6 +51,7 @@ class TMessageType {
   const CALL  = 1;
   const REPLY = 2;
   const EXCEPTION = 3;
+  const ONEWAY = 4;
 }
 
 /**
index 601b41c..21d7aa4 100644 (file)
@@ -40,6 +40,7 @@ class TMessageType:
   CALL  = 1
   REPLY = 2
   EXCEPTION = 3
+  ONEWAY = 4
 
 class TProcessor:
 
index 6d70eb5..20e4ca2 100644 (file)
@@ -94,6 +94,7 @@ module Thrift
     CALL = 1
     REPLY = 2
     EXCEPTION = 3
+    ONEWAY = 4
   end
 end