You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/07/06 09:57:01 UTC

[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #647: Ftr: experimentally distributed transaction based on seata-golang

AlexStocks commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r450113957



##########
File path: filter/filter_impl/seata_filter.go
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 filter_impl
+
+import (
+	"context"
+)
+
+import (
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/filter"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+const (
+	SEATA = "SEATA"
+	SEATA_XID = "SEATA_XID"
+)
+
+func init() {
+	extension.SetFilter(SEATA, GetSeataFilter)
+}
+
+// SeataFilter ...
+type SeataFilter struct {}
+
+// When use Seata, transfer xid by attachments
+// Invoke Get Xid by attachment key `SEATA_XID`
+func (sf *SeataFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
+	logger.Infof("invoking seata filter.")
+	xid := invocation.AttachmentsByKey(SEATA_XID,"")
+	if xid != "" {
+		logger.Debugf("Method: %v,Xid: %v", invocation.MethodName(), xid)
+		return invoker.Invoke(context.WithValue(ctx,SEATA_XID, xid), invocation)
+	}
+	return invoker.Invoke(ctx,invocation)
+}
+
+// OnResponse ...

Review comment:
       add comment for this func.

##########
File path: filter/filter_impl/seata_filter.go
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 filter_impl
+
+import (
+	"context"
+)
+
+import (
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/filter"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+const (
+	SEATA = "SEATA"
+	SEATA_XID = "SEATA_XID"
+)
+
+func init() {
+	extension.SetFilter(SEATA, GetSeataFilter)
+}
+
+// SeataFilter ...
+type SeataFilter struct {}
+
+// When use Seata, transfer xid by attachments
+// Invoke Get Xid by attachment key `SEATA_XID`
+func (sf *SeataFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
+	logger.Infof("invoking seata filter.")
+	xid := invocation.AttachmentsByKey(SEATA_XID,"")
+	if xid != "" {
+		logger.Debugf("Method: %v,Xid: %v", invocation.MethodName(), xid)
+		return invoker.Invoke(context.WithValue(ctx,SEATA_XID, xid), invocation)
+	}
+	return invoker.Invoke(ctx,invocation)
+}
+
+// OnResponse ...
+func (sf *SeataFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
+	return result
+}
+
+// GetSeataFilter ...

Review comment:
       add comment for this func.

##########
File path: filter/filter_impl/seata_filter.go
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 filter_impl
+
+import (
+	"context"
+)
+
+import (
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/filter"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+const (
+	SEATA = "SEATA"
+	SEATA_XID = "SEATA_XID"
+)
+
+func init() {
+	extension.SetFilter(SEATA, GetSeataFilter)
+}
+
+// SeataFilter ...

Review comment:
       add comment for this func.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org