|
|
@@ -19,14 +19,15 @@ package tcc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
|
|
|
"encoding/json" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"sync" |
|
|
"sync" |
|
|
|
|
|
|
|
|
"github.com/seata/seata-go/pkg/protocol/resource" |
|
|
|
|
|
"github.com/seata/seata-go/pkg/tm" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/seata/seata-go/pkg/common" |
|
|
"github.com/seata/seata-go/pkg/protocol/branch" |
|
|
"github.com/seata/seata-go/pkg/protocol/branch" |
|
|
|
|
|
"github.com/seata/seata-go/pkg/protocol/resource" |
|
|
"github.com/seata/seata-go/pkg/rm" |
|
|
"github.com/seata/seata-go/pkg/rm" |
|
|
|
|
|
"github.com/seata/seata-go/pkg/tm" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var ( |
|
|
var ( |
|
|
@@ -125,12 +126,22 @@ func (t *TCCResourceManager) BranchCommit(ctx context.Context, ranchType branch. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (t *TCCResourceManager) getBusinessActionContext(xid string, branchID int64, resourceID string, applicationData []byte) tm.BusinessActionContext { |
|
|
func (t *TCCResourceManager) getBusinessActionContext(xid string, branchID int64, resourceID string, applicationData []byte) tm.BusinessActionContext { |
|
|
|
|
|
var actionContextMap = make(map[string]interface{}, 2) |
|
|
|
|
|
if len(applicationData) > 0 { |
|
|
|
|
|
var tccContext map[string]interface{} |
|
|
|
|
|
if err := json.Unmarshal(applicationData, &tccContext); err != nil { |
|
|
|
|
|
panic("application data failed to unmarshl as json") |
|
|
|
|
|
} |
|
|
|
|
|
if v, ok := tccContext[common.ActionContext]; ok { |
|
|
|
|
|
actionContextMap = v.(map[string]interface{}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return tm.BusinessActionContext{ |
|
|
return tm.BusinessActionContext{ |
|
|
Xid: xid, |
|
|
|
|
|
BranchId: branchID, |
|
|
|
|
|
ActionName: resourceID, |
|
|
|
|
|
// todo get ActionContext |
|
|
|
|
|
//ActionContext:, |
|
|
|
|
|
|
|
|
Xid: xid, |
|
|
|
|
|
BranchId: branchID, |
|
|
|
|
|
ActionName: resourceID, |
|
|
|
|
|
ActionContext: &actionContextMap, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|