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 08:33:01 UTC

[GitHub] [dubbo-go] dk-lockdown opened a new pull request #647: support distributed transaction, by experimentally seata-golang

dk-lockdown opened a new pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647


   
   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:
   support distributed transaction, by experimentally [seata-golang](https://github.com/dk-lockdown/seata-golang)
   
   **Special notes for your reviewer**:
   this pr just added a filter, to receive xid from attachments
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


----------------------------------------------------------------
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


[GitHub] [dubbo-go] dk-lockdown commented on pull request #647: Ftr: experimentally distributed transaction based on seata-golang

Posted by GitBox <gi...@apache.org>.
dk-lockdown commented on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654659166


   > > > Can you provide a sample for this pr?
   > > > You can commit to the resposity as below
   > > > https://github.com/dubbogo/dubbo-samples
   > > 
   > > 
   > > samples 我写了准备提交到一个地方,但是我看了看,如果提交到 https://github.com/dubbogo/dubbo-samples ,ci 会过不了,因为这个还要和 tc server 端配合使用,并且还需要和数据库交互
   > 
   > It's ok,you can ignore travis CI in this project.But you must promise your sample must work. Don'f forget write a READEME.md
   
   好的,写了 readme.md 的


----------------------------------------------------------------
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


[GitHub] [dubbo-go] dk-lockdown commented on pull request #647: Ftr: experimentally distributed transaction based on seata-golang

Posted by GitBox <gi...@apache.org>.
dk-lockdown commented on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654629564


   > I have a question, can be used filter with grpc or rest when another server which is not a dubbo server invoke our service.
   
   should work


----------------------------------------------------------------
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


[GitHub] [dubbo-go] zouyx edited a comment on pull request #647: Ftr: experimentally distributed transaction based on seata-golang

Posted by GitBox <gi...@apache.org>.
zouyx edited a comment on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654650950


   > > Can you provide a sample for this pr?
   > > You can commit to the resposity as below
   > > https://github.com/dubbogo/dubbo-samples
   > 
   > samples 我写了准备提交到一个地方,但是我看了看,如果提交到 https://github.com/dubbogo/dubbo-samples ,ci 会过不了,因为这个还要和 tc server 端配合使用,并且还需要和数据库交互
   
   It's ok,you can ignore travis CI in this project.But you must promise your sample must work. Don'f forget write READEME.md


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
dk-lockdown commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r452035755



##########
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 when use seata-golang, use this filter to transfer xid
+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 != "" {

Review comment:
       “”, there is not a space, it is right




----------------------------------------------------------------
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


[GitHub] [dubbo-go] dk-lockdown commented on pull request #647: Ftr: experimentally distributed transaction based on seata-golang

Posted by GitBox <gi...@apache.org>.
dk-lockdown commented on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654625553


   > Can you provide a sample for this pr?
   > 
   > You can commit to the resposity as below
   > 
   > https://github.com/dubbogo/dubbo-samples
   
   samples 我写了准备提交到一个地方,但是我看了看,如果提交到 https://github.com/dubbogo/dubbo-samples ,ci 会过不了,因为这个还要和 tc server 端配合使用


----------------------------------------------------------------
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


[GitHub] [dubbo-go] dk-lockdown edited a comment on pull request #647: Ftr: experimentally distributed transaction based on seata-golang

Posted by GitBox <gi...@apache.org>.
dk-lockdown edited a comment on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654625553


   > Can you provide a sample for this pr?
   > 
   > You can commit to the resposity as below
   > 
   > https://github.com/dubbogo/dubbo-samples
   
   samples 我写了准备提交到一个地方,但是我看了看,如果提交到 https://github.com/dubbogo/dubbo-samples ,ci 会过不了,因为这个还要和 tc server 端配合使用,并且还需要和数据库交互


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
fangyincheng commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r451710014



##########
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"

Review comment:
       I suggest not to capitalize about value.




----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
AlexStocks merged pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647


   


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
zouyx commented on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654650950


   > > Can you provide a sample for this pr?
   > > You can commit to the resposity as below
   > > https://github.com/dubbogo/dubbo-samples
   > 
   > samples 我写了准备提交到一个地方,但是我看了看,如果提交到 https://github.com/dubbogo/dubbo-samples ,ci 会过不了,因为这个还要和 tc server 端配合使用,并且还需要和数据库交互
   
   It's ok,you can ignore travis CI in this project.But you must promise your sample must work. Don'f forget write a READEME.md


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r451979721



##########
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 when use seata-golang, use this filter to transfer xid
+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 != "" {

Review comment:
       if xid="        " will process if logic, is it right logic?




----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#issuecomment-654135672


   @dk-lockdown pls check the travis failure.


----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
dk-lockdown commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r452035755



##########
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 when use seata-golang, use this filter to transfer xid
+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 != "" {

Review comment:
       “”, no space, it is right




----------------------------------------------------------------
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


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

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #647:
URL: https://github.com/apache/dubbo-go/pull/647#discussion_r450625133



##########
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 when use seata-golang, use this filter to transfer xid
+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 dummy process, returns the result directly
+func (sf *SeataFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
+	return result
+}
+
+// GetSeataFilter create SeataFilter instance
+func GetSeataFilter() filter.Filter {

Review comment:
       why public method?




----------------------------------------------------------------
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