Browse Source

Update README.md

pull/339/head
yedf2 4 years ago
committed by GitHub
parent
commit
5287e9efa1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      README.md

16
README.md

@ -71,14 +71,14 @@ go run main.go
// The address where DtmServer serves DTM, which is a url
DtmServer := "http://localhost:36789/api/dtmsvr"
req := &gin.H{"amount": 30} // micro-service payload
// DtmServer is the address of DTM micro-service
saga := dtmcli.NewSaga(DtmServer, shortuuid.New()).
// add a TransOut sub-transaction,forward operation with url: qsBusi+"/TransOut", reverse compensation operation with url: qsBusi+"/TransOutCom"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCom", req).
// add a TransIn sub-transaction, forward operation with url: qsBusi+"/TransIn", reverse compensation operation with url: qsBusi+"/TransInCom"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCom", req)
// submit the created saga transaction,dtm ensures all sub-transactions either complete or get revoked
err := saga.Submit()
// DtmServer is the address of DTM micro-service
saga := dtmcli.NewSaga(DtmServer, shortuuid.New()).
// add a TransOut sub-transaction,forward operation with url: qsBusi+"/TransOut", reverse compensation operation with url: qsBusi+"/TransOutCom"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCom", req).
// add a TransIn sub-transaction, forward operation with url: qsBusi+"/TransIn", reverse compensation operation with url: qsBusi+"/TransInCom"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCom", req)
// submit the created saga transaction,dtm ensures all sub-transactions either complete or get revoked
err := saga.Submit()
```
When the above code runs, we can see in the console that services TransOut, TransIn has been called.

Loading…
Cancel
Save