You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/03 01:23:41 UTC

[GitHub] seanyinx commented on a change in pull request #98: [WIP]SCB-138 use grpc bidirectional streaming to connect alpha and omega

seanyinx commented on a change in pull request #98: [WIP]SCB-138 use grpc bidirectional streaming to connect alpha and omega
URL: https://github.com/apache/incubator-servicecomb-saga/pull/98#discussion_r159348811
 
 

 ##########
 File path: alpha/alpha-server/src/main/java/io/servicecomb/saga/alpha/server/GrpcOmegaCallback.java
 ##########
 @@ -0,0 +1,49 @@
+/*
+ *
+ * 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 io.servicecomb.saga.alpha.server;
+
+import com.google.protobuf.ByteString;
+
+import io.grpc.stub.StreamObserver;
+import io.servicecomb.saga.alpha.core.OmegaCallback;
+import io.servicecomb.saga.alpha.core.TxEvent;
+import io.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand;
+
+public class GrpcOmegaCallback implements OmegaCallback {
+
+  private final StreamObserver<GrpcCompensateCommand> observer;
+
+  public GrpcOmegaCallback(StreamObserver<GrpcCompensateCommand> observer) {
+    this.observer = observer;
+  }
+
+  @Override
+  public void compensate(TxEvent event) {
+    GrpcCompensateCommand command = GrpcCompensateCommand.newBuilder()
+        .setGlobalTxId(event.globalTxId())
+        .setLocalTxId(event.localTxId())
+        .setParentTxId(event.parentTxId().isEmpty() ? "" : event.parentTxId())
 
 Review comment:
   parentTxId will be null, if this sub tx has no parent.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services