jeremyxu2010 commented on issue #548: 使用go客户端连接servicecomb,有时候会报错
URL: 
https://github.com/apache/servicecomb-pack/issues/548#issuecomment-526914285
 
 
   @aresa7796 @tomatodady 
   
   很抱歉,由于目前在忙别的工作,确实很久没有更新该client库了。
   
   `servicecomb-pack`项目的向前兼容做得很好,我试着跑了下测试用例,暂时还是可正常工作的。
   
   
从上述报错信息来看,应该是使用`saga.DecorateSagaStartMethod`或`saga.DecorateCompensableMethod`装饰的方法返回值个数不正确,被装饰的方法返回值必须只能是一个error,见[参考测试用例](https://github.com/jeremyxu2010/matrix-saga-go/blob/master/test/sagatx_demo.go)。
   
   你也可以按以下指引先跑一遍测试用例看看
   
   ```bash
   # 克隆并编译servicecomb-pack项目
   $ git clone https://github.com/apache/servicecomb-pack.git
   $ cd servicecomb-pack
   $ mvn clean install -P 'mysql,!docker' -DskipTests=true
   
   # 初始化alpha-server依赖的数据库
   $ mysql -uroot -proot -h127.0.0.1 -P3306
   MariaDB [(none)]> create database saga;
   Query OK, 1 row affected (0.005 sec)
   
   MariaDB [(none)]> grant all privileges on saga.* to saga@'localhost' 
identified by 'saga';
   Query OK, 0 rows affected (0.045 sec)
   
   MariaDB [(none)]> flush privileges;
   
   MariaDB [(none)]> use saga
   Database changed
   
   MariaDB [saga]> source alpha/alpha-server/src/main/resources/schema-mysql.sql
   
   MariaDB [saga]> exit
   Bye
   
   # 启动alpha-server
   $ java -Dspring.profiles.active=mysql 
-D"spring.datasource.url=jdbc:mysql://127.0.0.1:3306/saga?useSSL=false" 
-D"spring.datasource.password=saga" -jar 
alpha/alpha-server/target/saga/alpha-server-0.6.0-SNAPSHOT-exec.jar
   ```
   
   另开一个shell终端,执行以下命令:
   
   ```bash
   # 克隆matrix-go-client项目并切换工作目录至matrix-saga-go目录
   $ git clone https://github.com/jeremyxu2010/matrix-saga-go.git
   $ cd matrix-saga-go
   # 使用go mod下载go module依赖
   $ go mod download
   # 运行测试用例,可以看到转帐过程中,foo和bar的帐户余额出现了短暂的不一致,但后面又达到了最终一致性,符合saga分布式事务的设计理念
   $ go run test/sagatx_demo.go
   foo balance: 500, bar balance: 500
   foo balance: 400, bar balance: 500
   foo balance: 500, bar balance: 500
   foo balance: 500, bar balance: 500
   ......
   ```
   
   这个go 
client库是一年前做的,当时`servicecomb-pack`的版本还是0.2.0版本。这一年时间`servicecomb-pack`发展挺快,有了不少变化,实现了相当多新的功能特性(TCC模式、AlphaServer
 HA、SagaEnd支持等)。后续我会抽时间,参考新版本的omega逐步完善本go client库,尽可能补上相关功能特性。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to