Business scenarios such as e-commerce transactions have high requirements for distributed transactions...
A simple e-commerce transaction scenario, an example of a distributed transaction solution implemented based on Dubbo-Go and Seata-Golang AT transaction patterns. See Seata for details on other transaction modes offered by Seata.
. ├── go-client │ ├── cmd │ ├── conf │ ├── pkg │ └── profiles │ └── dev ├── go-server-common │ └── filter ├── go-server-order │ ├── cmd │ ├── conf │ ├── docker │ └── pkg │ └── dao └── go-server-product ├── cmd ├── conf ├── docker └── pkg └── dao
Refer to HOWTO.md under the root directory to run this sample.
Configure the environment variable to specify the configuration file path required for the service to load
1.1 go-server-order
1.1.1 environment configuration
APP_LOG_CONF_FILE=shopping-order/go-server-order/conf/log.yml; CONF_PROVIDER_FILE_PATH=shopping-order/go-server-order/conf/server.yml; SEATA_CONF_FILE=shopping-order/go-server-order/conf/seata.yml
1.1.2 configuration file
modify server.yml
modify seata.yml
at: dsn: "username:password@tcp(mysql:3306)/seata_order?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8" report_retry_count: 5 report_success_enable: false lock_retry_interval: 10ms lock_retry_times: 30
1.2 go-server-product:
1.2.1 environment configuration
APP_LOG_CONF_FILE=shopping-order/go-server-product/conf/log.yml; CONF_PROVIDER_FILE_PATH=shopping-order/go-server-product/conf/server.yml; SEATA_CONF_FILE=shopping-order/go-server-product/conf/seata.yml
1.2.2 configuration file
modify server.yml
modify seata.yml
at: dsn: "username:password@tcp(mysql:3306)/seata_product?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8" report_retry_count: 5 report_success_enable: false lock_retry_interval: 10ms lock_retry_times: 30
1.3 go-client:
environment configuration:
APP_LOG_CONF_FILE=shopping-order/go-client/conf/log.yml; CONF_CONSUMER_FILE_PATH=shopping-order/go-client/conf/client.yml; SEATA_CONF_FILE=shopping-order/go-client/conf/seata.yml
This example uses ZooKeeper as the registry, so you can run the Docker ZooKeeper environment directly. See docker-compose.yml
See: seata-golang , seata
- Order Service
- Product services
${project_dir}/.run/shopping-order
. ├── go-client.run.xml ├── order-go-server.run.xml └── product-go-server.run.xml
Refer to HOWTO.md under the root directory to run this sample.