You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2017/06/16 15:27:05 UTC

[2/2] camel git commit: CAMEL-11236: renaming gRPC RPC mode to SIMPLE

CAMEL-11236: renaming gRPC RPC mode to SIMPLE


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/04191e54
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/04191e54
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/04191e54

Branch: refs/heads/master
Commit: 04191e541839052fd036f04444d22494186e7292
Parents: 0def063
Author: Nicola Ferraro <ni...@gmail.com>
Authored: Fri Jun 16 17:26:43 2017 +0200
Committer: Nicola Ferraro <ni...@gmail.com>
Committed: Fri Jun 16 17:26:43 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/grpc-component.adoc           |  4 +-
 .../camel/component/grpc/GrpcConfiguration.java |  8 +--
 .../component/grpc/GrpcProducerStrategy.java    |  2 +-
 .../client/GrpcExchangeForwarderFactory.java    |  4 +-
 .../grpc/client/GrpcRPCExchangeForwarder.java   | 65 --------------------
 .../client/GrpcSimpleExchangeForwarder.java     | 65 ++++++++++++++++++++
 6 files changed, 74 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/docs/grpc-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/docs/grpc-component.adoc b/components/camel-grpc/src/main/docs/grpc-component.adoc
index 65130f2..95820de 100644
--- a/components/camel-grpc/src/main/docs/grpc-component.adoc
+++ b/components/camel-grpc/src/main/docs/grpc-component.adoc
@@ -57,11 +57,11 @@ with the following path and query parameters:
 | **host** (common) | The gRPC server host name |  | String
 | **port** (common) | The gRPC server port |  | int
 | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean
-| **consumerStrategy** (consumer) | This option specifies the top-level strategy for processing service requests and responses in streaming mode. If an aggregation strategy is selected all requests will be accumulated in the list then transferred to the flow and the accumulated responses will be sent to the sender. If a propagation strategy is selected request is sent to the stream and the response will be immediately sent back to the sender. |  | GrpcConsumerStrategy
+| **consumerStrategy** (consumer) | This option specifies the top-level strategy for processing service requests and responses in streaming mode. If an aggregation strategy is selected all requests will be accumulated in the list then transferred to the flow and the accumulated responses will be sent to the sender. If a propagation strategy is selected request is sent to the stream and the response will be immediately sent back to the sender. | PROPAGATION | GrpcConsumerStrategy
 | **exceptionHandler** (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | **exchangePattern** (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
 | **method** (producer) | gRPC method name |  | String
-| **producerStrategy** (producer) | The mode used to communicate with a remote gRPC server. In RPC mode a single exchange is translated to a remote call. In STREAMING mode all exchanges will be sent within the same request (input and output of the recipient gRPC service must be of type 'stream'). |  | GrpcProducerStrategy
+| **producerStrategy** (producer) | The mode used to communicate with a remote gRPC server. In SIMPLE mode a single exchange is translated into a remote procedure call. In STREAMING mode all exchanges will be sent within the same request (input and output of the recipient gRPC service must be of type 'stream'). | SIMPLE | GrpcProducerStrategy
 | **streamRepliesTo** (producer) | When using STREAMING client mode it indicates the endpoint where responses should be forwarded. |  | String
 | **target** (producer) | The channel target name as alternative to host and port parameters |  | String
 | **usePlainText** (producer) | The plain text connection to the server flag | true | Boolean

http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
index f37d0cf..3a708d8 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
@@ -43,14 +43,14 @@ public class GrpcConfiguration {
     @UriParam(label = "producer", defaultValue = "true")
     private Boolean usePlainText = true;
 
-    @UriParam(label = "producer")
-    private GrpcProducerStrategy producerStrategy = GrpcProducerStrategy.RPC;
+    @UriParam(label = "producer", defaultValue = "SIMPLE")
+    private GrpcProducerStrategy producerStrategy = GrpcProducerStrategy.SIMPLE;
 
     @UriParam(label = "producer")
     private String streamRepliesTo;
 
 
-    @UriParam(label = "consumer")
+    @UriParam(label = "consumer", defaultValue = "PROPAGATION")
     private GrpcConsumerStrategy consumerStrategy = GrpcConsumerStrategy.PROPAGATION;
     
     @UriParam(defaultValue = "false")
@@ -196,7 +196,7 @@ public class GrpcConfiguration {
 
     /**
      * The mode used to communicate with a remote gRPC server.
-     * In RPC mode a single exchange is translated to a remote call.
+     * In SIMPLE mode a single exchange is translated into a remote procedure call.
      * In STREAMING mode all exchanges will be sent within the same request (input and output of the recipient gRPC service must be of type 'stream').
      */
     public void setProducerStrategy(GrpcProducerStrategy producerStrategy) {

http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducerStrategy.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducerStrategy.java
index e94c4b7..f0cbeb4 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducerStrategy.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducerStrategy.java
@@ -24,7 +24,7 @@ public enum GrpcProducerStrategy {
     /**
      * Transform each exchange into a RPC.
      */
-    RPC,
+    SIMPLE,
 
     /**
      * Forward each exchange using a shared gRPC request.

http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcExchangeForwarderFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcExchangeForwarderFactory.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcExchangeForwarderFactory.java
index f4dc9d6..2b92d43 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcExchangeForwarderFactory.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcExchangeForwarderFactory.java
@@ -28,8 +28,8 @@ public final class GrpcExchangeForwarderFactory {
     }
 
     public static GrpcExchangeForwarder createExchangeForwarder(GrpcConfiguration configuration, Object grpcStub) {
-        if (configuration.getProducerStrategy() == GrpcProducerStrategy.RPC) {
-            return new GrpcRPCExchangeForwarder(configuration, grpcStub);
+        if (configuration.getProducerStrategy() == GrpcProducerStrategy.SIMPLE) {
+            return new GrpcSimpleExchangeForwarder(configuration, grpcStub);
         } else if (configuration.getProducerStrategy() == GrpcProducerStrategy.STREAMING) {
             return new GrpcStreamingExchangeForwarder(configuration, grpcStub);
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcRPCExchangeForwarder.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcRPCExchangeForwarder.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcRPCExchangeForwarder.java
deleted file mode 100644
index 0ff9c6c..0000000
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcRPCExchangeForwarder.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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 regarding copyright ownership.
- * The ASF licenses this file 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.
- */
-package org.apache.camel.component.grpc.client;
-
-import io.grpc.stub.StreamObserver;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.component.grpc.GrpcConfiguration;
-import org.apache.camel.component.grpc.GrpcUtils;
-
-/**
- * An exchange forwarder that creates a RPC request for each camel Exchange.
- */
-class GrpcRPCExchangeForwarder implements GrpcExchangeForwarder {
-
-    private final GrpcConfiguration configuration;
-
-    private final Object grpcStub;
-
-    public GrpcRPCExchangeForwarder(GrpcConfiguration configuration, Object grpcStub) {
-        this.configuration = configuration;
-        this.grpcStub = grpcStub;
-
-    }
-
-    @Override
-    public boolean forward(Exchange exchange, StreamObserver<Object> responseObserver, AsyncCallback callback) {
-        Message message = exchange.getIn();
-        try {
-            GrpcUtils.invokeAsyncMethod(grpcStub, configuration.getMethod(), message.getBody(), responseObserver);
-        } catch (Exception e) {
-            exchange.setException(e);
-            callback.done(true);
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void forward(Exchange exchange) {
-        Message message = exchange.getIn();
-        Object outBody = GrpcUtils.invokeSyncMethod(grpcStub, configuration.getMethod(), message.getBody());
-        exchange.getOut().setBody(outBody);
-    }
-
-    @Override
-    public void shutdown() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/04191e54/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcSimpleExchangeForwarder.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcSimpleExchangeForwarder.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcSimpleExchangeForwarder.java
new file mode 100644
index 0000000..4a497b5
--- /dev/null
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/client/GrpcSimpleExchangeForwarder.java
@@ -0,0 +1,65 @@
+/**
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component.grpc.client;
+
+import io.grpc.stub.StreamObserver;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.component.grpc.GrpcConfiguration;
+import org.apache.camel.component.grpc.GrpcUtils;
+
+/**
+ * An exchange forwarder that creates a RPC request for each camel Exchange.
+ */
+class GrpcSimpleExchangeForwarder implements GrpcExchangeForwarder {
+
+    private final GrpcConfiguration configuration;
+
+    private final Object grpcStub;
+
+    public GrpcSimpleExchangeForwarder(GrpcConfiguration configuration, Object grpcStub) {
+        this.configuration = configuration;
+        this.grpcStub = grpcStub;
+
+    }
+
+    @Override
+    public boolean forward(Exchange exchange, StreamObserver<Object> responseObserver, AsyncCallback callback) {
+        Message message = exchange.getIn();
+        try {
+            GrpcUtils.invokeAsyncMethod(grpcStub, configuration.getMethod(), message.getBody(), responseObserver);
+        } catch (Exception e) {
+            exchange.setException(e);
+            callback.done(true);
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void forward(Exchange exchange) {
+        Message message = exchange.getIn();
+        Object outBody = GrpcUtils.invokeSyncMethod(grpcStub, configuration.getMethod(), message.getBody());
+        exchange.getOut().setBody(outBody);
+    }
+
+    @Override
+    public void shutdown() {
+    }
+}