Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问这种场景应该怎么使用呀?需要根据条件再开启一个事务。 #518

Open
dahvlhldle opened this issue Aug 16, 2024 · 1 comment

Comments

@dahvlhldle
Copy link

dahvlhldle commented Aug 16, 2024

请问这种场景应该怎么使用呀?需要根据条件再开启一个事务。如果这么调用内部会调用2次 tx.Commit()

` barrier, err := dtmgrpc.BarrierFromGrpc(ctx)
	if err != nil {
		return nil, err
	}
	tx := db.Begin()
	sourceTx := tx.Statement.ConnPool.(*sql.Tx)
	return &emptypb.Empty{}, barrier.Call(sourceTx, func(_ *sql.Tx) error {
		return ( tx *gorm.DB)error{
if condition {
msg:=	dtmgrpc.NewMsgGrpc(host, gid)
msg.Add(...)
err := msg.DoAndSubmit(QueryPrepare, func(bb *dtmcli.BranchBarrier) error {
	return bb.Call(sourceTx, func(tx *sql.Tx) error {
		return nil
	})
})
}}()
	})
}`
@yedf2
Copy link
Contributor

yedf2 commented Sep 16, 2024

这个看不太清晰,最后能够把业务描述清楚,代码里面最好能把业务代码用函数调用代表,并加上说明

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants