You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/06/20 15:54:36 UTC
[dubbo-go-samples] branch 3.0 updated: Fix: seata panic ,
attachment to AttachmentKey (#148)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/3.0 by this push:
new d113ee8 Fix: seata panic , attachment to AttachmentKey (#148)
d113ee8 is described below
commit d113ee8f5f8952187960d74f6006c709b0059943
Author: phil <ph...@foxmail.com>
AuthorDate: Sun Jun 20 23:54:30 2021 +0800
Fix: seata panic , attachment to AttachmentKey (#148)
* fix: seata panic , attachment to AttachmentKey
* update: the standard of import dependency
Co-authored-by: yuefengbo <yu...@meituan.com>
---
seata/client/app/client.go | 16 +++++++---------
seata/client/app/svc/svc.go | 18 +++++++++---------
seata/order-svc/app/dao/dao.go | 5 +----
seata/order-svc/app/order_svc.go | 9 +++++----
seata/order-svc/app/server.go | 18 ++++++++----------
seata/product-svc/app/product_svc.go | 9 +++++----
seata/product-svc/app/server.go | 18 ++++++++----------
7 files changed, 43 insertions(+), 50 deletions(-)
diff --git a/seata/client/app/client.go b/seata/client/app/client.go
index ed438ef..71d1cd9 100644
--- a/seata/client/app/client.go
+++ b/seata/client/app/client.go
@@ -27,24 +27,22 @@ import (
)
import (
- "github.com/apache/dubbo-go-samples/seata/client/app/svc"
-)
-
-import (
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
"github.com/transaction-wg/seata-golang/pkg/client"
config2 "github.com/transaction-wg/seata-golang/pkg/client/config"
"github.com/transaction-wg/seata-golang/pkg/client/tm"
+)
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
-
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
+import (
+ "github.com/apache/dubbo-go-samples/seata/client/app/svc"
)
const (
diff --git a/seata/client/app/svc/svc.go b/seata/client/app/svc/svc.go
index ab219e6..e201dfa 100644
--- a/seata/client/app/svc/svc.go
+++ b/seata/client/app/svc/svc.go
@@ -19,20 +19,20 @@ package svc
import (
"context"
- "dubbo.apache.org/dubbo-go/v3/config"
- "github.com/apache/dubbo-go-samples/seata/filter"
-
"errors"
)
import (
- "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
- dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
+ "github.com/transaction-wg/seata-golang/pkg/client/tm"
)
import (
- context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
- "github.com/transaction-wg/seata-golang/pkg/client/tm"
+ "github.com/apache/dubbo-go-samples/seata/filter"
+ "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
+ dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
)
type OrderSvc struct {
@@ -102,7 +102,7 @@ func (svc *Svc) CreateSo(ctx context.Context, rollback bool) ([]uint64, error) {
var allocateInventoryResult = &dao2.AllocateInventoryResult{}
// 通过 attachment 传递 xid
- err1 := orderSvc.CreateSo(context.WithValue(ctx, "attachment", map[string]string{
+ err1 := orderSvc.CreateSo(context.WithValue(ctx, constant.AttachmentKey, map[string]interface{}{
filter.SEATA_XID: rootContext.GetXID(),
}), soMasters, createSoResult)
if err1 != nil {
@@ -110,7 +110,7 @@ func (svc *Svc) CreateSo(ctx context.Context, rollback bool) ([]uint64, error) {
}
// 通过 attachment 传递 xid
- err2 := productSvc.AllocateInventory(context.WithValue(ctx, "attachment", map[string]string{
+ err2 := productSvc.AllocateInventory(context.WithValue(ctx, constant.AttachmentKey, map[string]interface{}{
filter.SEATA_XID: rootContext.GetXID(),
}), reqs, allocateInventoryResult)
if err2 != nil {
diff --git a/seata/order-svc/app/dao/dao.go b/seata/order-svc/app/dao/dao.go
index a216fae..606dd77 100644
--- a/seata/order-svc/app/dao/dao.go
+++ b/seata/order-svc/app/dao/dao.go
@@ -18,15 +18,12 @@
package dao
import (
- hessian "github.com/apache/dubbo-go-hessian2"
"time"
)
import (
+ hessian "github.com/apache/dubbo-go-hessian2"
"github.com/bwmarrin/snowflake"
-)
-
-import (
"github.com/transaction-wg/seata-golang/pkg/client/at/exec"
"github.com/transaction-wg/seata-golang/pkg/client/context"
)
diff --git a/seata/order-svc/app/order_svc.go b/seata/order-svc/app/order_svc.go
index e76af65..825cf67 100644
--- a/seata/order-svc/app/order_svc.go
+++ b/seata/order-svc/app/order_svc.go
@@ -22,12 +22,13 @@ import (
)
import (
- "github.com/apache/dubbo-go-samples/seata/filter"
- dao2 "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
)
import (
- context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
+ "github.com/apache/dubbo-go-samples/seata/filter"
+ dao2 "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
)
type OrderSvc struct {
@@ -35,7 +36,7 @@ type OrderSvc struct {
}
func (svc *OrderSvc) CreateSo(ctx context.Context, reqs []*dao2.SoMaster) (*dao2.CreateSoResult, error) {
- attach := ctx.Value("attachment").(map[string]interface{})
+ attach := ctx.Value(constant.AttachmentKey).(map[string]interface{})
val := attach[filter.SEATA_XID]
xid := val.(string)
diff --git a/seata/order-svc/app/server.go b/seata/order-svc/app/server.go
index f2d69e6..08e308c 100644
--- a/seata/order-svc/app/server.go
+++ b/seata/order-svc/app/server.go
@@ -27,24 +27,22 @@ import (
)
import (
- dao2 "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
-)
-
-import (
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
+ _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
"github.com/transaction-wg/seata-golang/pkg/client"
"github.com/transaction-wg/seata-golang/pkg/client/at/exec"
config2 "github.com/transaction-wg/seata-golang/pkg/client/config"
+)
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
-
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
+import (
+ dao2 "github.com/apache/dubbo-go-samples/seata/order-svc/app/dao"
)
const (
diff --git a/seata/product-svc/app/product_svc.go b/seata/product-svc/app/product_svc.go
index 07f93ee..91d74c9 100644
--- a/seata/product-svc/app/product_svc.go
+++ b/seata/product-svc/app/product_svc.go
@@ -22,12 +22,13 @@ import (
)
import (
- "github.com/apache/dubbo-go-samples/seata/filter"
- dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
)
import (
- context2 "github.com/transaction-wg/seata-golang/pkg/client/context"
+ "github.com/apache/dubbo-go-samples/seata/filter"
+ dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
)
type ProductSvc struct {
@@ -35,7 +36,7 @@ type ProductSvc struct {
}
func (svc *ProductSvc) AllocateInventory(ctx context.Context, reqs []*dao2.AllocateInventoryReq) (*dao2.AllocateInventoryResult, error) {
- attach := ctx.Value("attachment").(map[string]interface{})
+ attach := ctx.Value(constant.AttachmentKey).(map[string]interface{})
val := attach[filter.SEATA_XID]
xid := val.(string)
diff --git a/seata/product-svc/app/server.go b/seata/product-svc/app/server.go
index b40306c..6d3f420 100644
--- a/seata/product-svc/app/server.go
+++ b/seata/product-svc/app/server.go
@@ -27,24 +27,22 @@ import (
)
import (
- dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
-)
-
-import (
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
+ _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
+ _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
"github.com/transaction-wg/seata-golang/pkg/client"
"github.com/transaction-wg/seata-golang/pkg/client/at/exec"
config2 "github.com/transaction-wg/seata-golang/pkg/client/config"
+)
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
-
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- _ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
+import (
+ dao2 "github.com/apache/dubbo-go-samples/seata/product-svc/app/dao"
)
const (