forked from apache/dubbo-go-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update README, remove 'dubbo' sub dir from 'helloworld'
- Loading branch information
Showing
35 changed files
with
806 additions
and
806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,147 +1,147 @@ | ||
# examples | ||
# Dubbo Golang Examples | ||
|
||
Examples of dubbo-go | ||
## What It Contains | ||
|
||
## What does this contain | ||
|
||
* helloworld | ||
|
||
A simplest example. It contain 'go-client', 'go-server', 'java-server' of dubbo protocol. | ||
|
||
* direct | ||
|
||
A direct example. This feature make start of dubbo-go get easy. | ||
|
||
* async | ||
|
||
An async example. dubbo-go supports client to call server asynchronously. | ||
|
||
* general | ||
|
||
A general example. It had validated zookeeper registry and different parameter lists of service. | ||
* helloworld: A simplest example. It contain 'go-client', 'go-server', 'java-server' of dubbo protocol. | ||
* direct: A direct example. This feature make start of dubbo-go get easy. | ||
* async: An async example. dubbo-go supports client to call server asynchronously. | ||
* general: A general example. It had validated zookeeper registry and different parameter lists of service. | ||
And it has a comprehensive testing with dubbo/jsonrpc/grpc/rest protocol. You can refer to it to create your first complete dubbo-go project. | ||
* generic: A generic example. It show how to use generic feature of dubbo-go. | ||
* configcenter: Some examples of different config center. There are three -- zookeeper, apollo and nacos at present. | ||
* multi_registry: An example of multiple registries. | ||
* registry: Some examples of different registry. There are kubernetes, nacos and etcd at present. **Note**: When use the different registry, you need update config file, but also must import the registry package. see the etcd `README` | ||
* filter: Some examples of different filter. Including custom_filter and tpslimit | ||
* router: Some router examples. Now, a condition router example is existing. | ||
* seata: Transaction system examples by seata. | ||
* shop: Shop sample, make consumer and provider run in a go program. | ||
* tracing: Some tracing examples. We have tracing support of dubbo/grpc/jsonrpc protocol at present. | ||
|
||
## How To Run | ||
|
||
* generic | ||
> Take `helloworld` as an example | ||
A generic example. It show how to use generic feature of dubbo-go. | ||
#### 1. Setup Zookeeper Server | ||
|
||
* configcenter | ||
A [zookeeper](https://zookeeper.apache.org/releases.html) server is required to run most of the samples in this repository. It can either start without docker environment like this: | ||
|
||
Some examples of different config center. There are three -- zookeeper, apollo and nacos at present. | ||
```bash | ||
zkServer start | ||
``` | ||
|
||
* multi_registry | ||
or start when docker environment presents: | ||
|
||
An example of multiple registries. | ||
```bash | ||
docker run --name zookeeper -p2181:2181 -d zookeeper | ||
``` | ||
|
||
* registry | ||
This samples repository provides an even more convenient way to start zookeeper: | ||
|
||
Some examples of different registry. There are kubernetes, nacos and etcd at present. | ||
```bash | ||
cd helloworld/go-server | ||
make -f ../../build/Makefile docker-up | ||
``` | ||
|
||
**Note**: | ||
Once the following messages outputs, the zookeeper server is ready. | ||
|
||
When use different registry, you need update config file, but also must import the registry package. see the etcd `README` | ||
```bash | ||
> Starting dependency services with docker/docker-compose.yml | ||
Creating network "docker_default" with the default driver | ||
Creating docker_zookeeper_1 ... done | ||
``` | ||
|
||
* filter | ||
To shutdown it, simple run | ||
|
||
Some examples of different filter. Including custom_filter and tpslimit | ||
* router | ||
```bash | ||
make -f ~/github/apache/dubbo-go-samples/build/Makefile docker-down | ||
``` | ||
|
||
Some router examples. Now, a condition router example is existing. | ||
#### 2. Start go-server | ||
|
||
* seata | ||
Use the following commands to start `go-server`. | ||
|
||
Transaction system examples by seata. | ||
```bash | ||
cd helloworld/go-server | ||
make -f ../../build/Makefile start | ||
``` | ||
|
||
* shop | ||
Once the following messages outputs, the server is ready. | ||
|
||
Shop sample, make consumer and provider run in a go program. | ||
|
||
* tracing | ||
```bash | ||
> Buiding application binary: dist/darwin_amd64/release/go-server | ||
> Starting application go-server, output is redirected to dist/darwin_amd64/release/go-server.log | ||
> PID: 86428 | ||
``` | ||
|
||
Some tracing examples. We have tracing support of dubbo/grpc/jsonrpc protocol at present. | ||
The output of `go-server` can be found from 'dist/darwin_amd64/release/go-server.log'. | ||
|
||
## How to build and run | ||
#### 3. Run go-client | ||
|
||
> Take `helloworld` as an example | ||
java server | ||
Use the following commands to run `go-client`. | ||
|
||
```bash | ||
cd helloworld/dubbo/java-server | ||
sh build.sh | ||
cd ./target | ||
tar -zxvf user-info-server-0.2.0-assembly.tar.gz | ||
cd ./user-info-server-0.2.0 | ||
sh ./bin/server.sh start | ||
cd helloworld/go-client | ||
make -f ../../build/Makefile run | ||
``` | ||
|
||
java client | ||
Once the following messages outputs, the `go-client` calls the `go-server` successfully. | ||
|
||
```bash | ||
cd helloworld/dubbo/java-client | ||
sh build.sh | ||
cd ./target | ||
tar -zxvf user-info-client-0.2.0-assembly.tar.gz | ||
cd ./user-info-client-0.2.0 | ||
sh ./bin/server.sh start | ||
> Buiding application binary: dist/darwin_amd64/release/go-client | ||
> Running application go-client, output is redirected to dist/darwin_amd64/release/go-client.log | ||
... | ||
2020-10-27T14:51:37.520+0800 DEBUG dubbo/dubbo_invoker.go:144 result.Err: <nil>, result.Rest: &{A001 Alex Stocks 18 2020-10-27 14:51:37.52 +0800 CST} | ||
2020-10-27T14:51:37.520+0800 DEBUG proxy/proxy.go:177 [makeDubboCallProxy] result: &{A001 Alex Stocks 18 2020-10-27 14:51:37.52 +0800 CST}, err: <nil> | ||
response result: &{A001 Alex Stocks 18 2020-10-27 14:51:37.52 +0800 CST} | ||
``` | ||
|
||
go server | ||
#### 4. Integration Test | ||
|
||
* $ARCH = [linux, mac, windows] and $ENV = [dev, release, test] | ||
dubbo-go-samples is designed to serve the purposes of not only the show cases of how to use apache/dubbo-go but also the integration-test for apache/dubbo-go. To run integration test for `go-server`, run the following commands: | ||
|
||
```bash | ||
cd helloworld/dubbo/go-server | ||
sh ./assembly/$ARCH/$ENV.sh | ||
cd ./target/$ARCH/user_info_server-0.3.1-20190517-0930-release | ||
# $SUFFIX is a suffix of config file, | ||
# such as server_zookeeper.yml when $SUFFIX is "zookeeper", | ||
# if $SUFFIX = "", default server.yml | ||
sh ./bin/load.sh start $SUFFIX | ||
cd helloworld/go-server | ||
make -f ../../build/Makefile integration | ||
``` | ||
|
||
go client | ||
|
||
* $ARCH = [linux, mac, windows] and $ENV = [dev, release, test] | ||
Once the following messages outputs, the integration tests pass. | ||
|
||
```bash | ||
cd helloworld/dubbo/go-client | ||
sh ./assembly/$ARCH/$ENV.sh | ||
cd ./target/$ARCH/user_info_client-0.3.1-20190517-0921-release | ||
# $SUFFIX is a suffix of config file, | ||
# such as client_zookeeper.yml when $SUFFIX = zookeeper", | ||
# if $SUFFIX = "", config file is client.yml | ||
sh ./bin/load_user_info_client.sh start $SUFFIX | ||
> Running integration test for application go-server | ||
... | ||
--- PASS: TestGetUser (0.00s) | ||
PASS | ||
ok github.com/apache/dubbo-samples/golang/helloworld/go-server/tests/integration 3.603s | ||
``` | ||
|
||
docker env | ||
#### 5. Clean Up | ||
|
||
To clean up, run the following command: | ||
|
||
```bash | ||
docker run -d --name zk zookeeper | ||
docker run -d --network container:zk registry.cn-hangzhou.aliyuncs.com/scottwang/go-server | ||
docker run -d --network container:zk registry.cn-hangzhou.aliyuncs.com/scottwang/go-client | ||
cd helloworld/go-server | ||
make -f ../../build/Makefile clean | ||
make -f ../../build/Makefile docker-down | ||
``` | ||
|
||
## How to debug with Goland | ||
|
||
### Edit Configurations | ||
#### 1. Edit Configurations | ||
|
||
![](.images/edit_configuratios.png) | ||
|
||
### Configure `Environment Variable` | ||
|
||
1. Add `APP_LOG_CONF_FILE`. eg: `/home/xx/dubbogo-samples/helloworld/client/conf/log.yml` | ||
2. Add `CONF_CONSUMER_FILE_PATH` eg: `/home/xx/dubbogo-samples/helloworld/client/conf/client.yml` | ||
3. Add `CONF_PROVIDER_FILE_PATH` eg: `/home/xx/dubbogo-samples/helloworld/server/conf/server.yml` | ||
#### 2. Configure `Environment Variable` | ||
|
||
* Add `APP_LOG_CONF_FILE`. eg: `/home/xx/dubbogo-samples/helloworld/client/conf/log.yml` | ||
* Add `CONF_CONSUMER_FILE_PATH` eg: `/home/xx/dubbogo-samples/helloworld/client/conf/client.yml` | ||
* Add `CONF_PROVIDER_FILE_PATH` eg: `/home/xx/dubbogo-samples/helloworld/server/conf/server.yml` | ||
![](.images/edit_env.png) | ||
|
||
### Apply & Run | ||
Click Apply, then you are all set to run. | ||
|
||
## How to contribute | ||
|
||
If you want to add some samples, we hope that you can do this: | ||
1. Adding samples in appropriate directory. If you dont' know which directory you should put your samples into, you can get some advices from dubbo-go community. | ||
2. You must run the samples locally and there must be no any error. | ||
3. If your samples have some third party dependency, including another framework, we hope that you can provide some docs, script is better. | ||
4. Please make pr to https://github.com/dubbogo/dubbo-samples instead of https://github.com/apache/dubbo-samples. We will synchronize to apache/dubbo-samples regularly. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.