Browse Source

fix xa test

topic
yedf2 5 years ago
parent
commit
62d7509ff4
  1. 15
      README.md
  2. 4
      examples/main_xa.go

15
README.md

@ -81,9 +81,9 @@ Configure mysql:
Refer to [examples/quick_start.go](./examples/quick_start.go)
## [sub-transaction barrier](./doc/barrier-en.md)
### [sub-transaction barrier](./doc/barrier-en.md)
## [protocol](./doc/protocol-en.md)
### [protocol](./doc/protocol-en.md)
### Wechat Group
@ -98,3 +98,14 @@ If you think this project is good, or helpful to you, please give a star!
<img alt='ivydad' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img>
<img alt='eglass' height='40' src='https://img.epeijing.cn/official-website/assets/logo.png' /img>
</div>
### Following is keyword for SEO
分布式事务框架
事务消息
可靠消息
微服务

4
examples/main_xa.go

@ -65,7 +65,7 @@ func XaFireRequest() string {
func xaTransIn(c *gin.Context) (interface{}, error) {
err := XaClient.XaLocalTransaction(c, func(db *common.DB, xa *dtmcli.Xa) (rerr error) {
req := reqFrom(c)
if req.TransInResult != "SUCCESS" {
if req.TransInResult == "FAILURE" {
return fmt.Errorf("tranIn FAILURE")
}
dbr := db.Exec("update user_account set balance=balance+? where user_id=?", req.Amount, 2)
@ -81,7 +81,7 @@ func xaTransIn(c *gin.Context) (interface{}, error) {
func xaTransOut(c *gin.Context) (interface{}, error) {
err := XaClient.XaLocalTransaction(c, func(db *common.DB, xa *dtmcli.Xa) (rerr error) {
req := reqFrom(c)
if req.TransOutResult != "SUCCESS" {
if req.TransOutResult == "FAILURE" {
return fmt.Errorf("tranOut failed")
}
dbr := db.Exec("update user_account set balance=balance-? where user_id=?", req.Amount, 1)

Loading…
Cancel
Save