Skip to content

Commit 4af0861

Browse files
authored
Merge pull request apache#2 from apache/master
merge origin
2 parents ec4fd0b + 9b21628 commit 4af0861

File tree

101 files changed

+3720
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3720
-261
lines changed

.images/edit_configuratios.png

-181 KB
Binary file not shown.

.images/edit_env.png

-185 KB
Binary file not shown.

.images/run-configurations.png

65.2 KB
Loading

.run/attachment-go-client.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="attachment-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/attachment/go-client/conf/log.yml" />
7+
<env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/attachment/go-client/conf/client.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/attachment/go-client/cmd/client.go" />
11+
<package value="github.com/apache/dubbo-go-samples/attachment/go-client/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

.run/attachment-go-server.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="attachment-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/attachment/go-server/conf/server.yml" />
7+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/attachment/go-server/conf/log.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/attachment/go-server/cmd/server.go" />
11+
<package value="github.com/apache/dubbo-go-samples/attachment/go-server/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

.run/helloworld-go-client.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="helloworld-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/helloworld/go-client/conf/log.yml" />
7+
<env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/helloworld/go-client/conf/client.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/helloworld/go-client/cmd/client.go" />
11+
<package value="github.com/apache/dubbo-go-samples/helloworld/go-client/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

.run/helloworld-go-server.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="helloworld-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/helloworld/go-server/conf/log.yml" />
7+
<env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/helloworld/go-server/conf/server.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/helloworld/go-server/cmd/server.go" />
11+
<package value="github.com/apache/dubbo-go-samples/helloworld/go-server/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

.run/metric-go-client.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="metric-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/metric/go-client/conf/log.yml" />
7+
<env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/metric/go-client/conf/client.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/metric/go-client/cmd/client.go" />
11+
<package value="github.com/apache/dubbo-go-samples/metric/go-client/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

.run/metric-go-server.run.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="metric-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" singleton="false">
3+
<module name="dubbo-go-samples" />
4+
<working_directory value="$PROJECT_DIR$" />
5+
<envs>
6+
<env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/metric/go-server/conf/server.yml" />
7+
<env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/metric/go-server/conf/log.yml" />
8+
</envs>
9+
<kind value="PACKAGE" />
10+
<filePath value="$PROJECT_DIR$/metric/go-server/cmd/server.go" />
11+
<package value="github.com/apache/dubbo-go-samples/metric/go-server/cmd" />
12+
<directory value="$PROJECT_DIR$" />
13+
<method v="2" />
14+
</configuration>
15+
</component>

HOWTO.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# How To Run
2+
3+
There are three ways to run dubbo-go samples:
4+
5+
1. Quick start with makefile: a common makefile is provided under "build" subdirectory, which can be used to run each sample here quickly. It is also useful to run all samples automatically so that now it is possible to leverage samples as dubbo-go's integration test.
6+
2. Quick start in IDE (**Recommended**): In ".run" subdirectory a couple of GoLand run configuration files are provided so that user can run each sample with just one click.
7+
3. Manually config and run in IDE: For completeness purpose, a step-by-step instruction is also provided so that user can understand how to configure and run or debug a sample in IDE.
8+
9+
### 1. Quick start with makefile
10+
11+
*Prerequisite: docker environment is required*
12+
13+
Here we use "attachment" as an example:
14+
15+
1. **Start register server (e.g. zookeeper)**
16+
17+
```bash
18+
cd attachment/server
19+
make -f ../../build/Makefile docker-up
20+
```
21+
22+
Once the following messages outputs, the zookeeper server is ready.
23+
24+
```bash
25+
> Starting dependency services with docker/docker-compose.yml
26+
Creating network "docker_default" with the default driver
27+
Creating docker_zookeeper_1 ... done
28+
```
29+
30+
To shut it down, simple run
31+
32+
```bash
33+
cd attachment/server
34+
make -f ../../build/Makefile docker-down
35+
```
36+
37+
2. **Start server**
38+
39+
```bash
40+
cd attachment/server
41+
make -f ../../build/Makefile start
42+
```
43+
44+
Once the following messages outputs, the server is ready.
45+
46+
```bash
47+
> Buiding application binary: dist/darwin_amd64/release/go-server
48+
> Starting application go-server, output is redirected to dist/darwin_amd64/release/go-server.log
49+
> PID: 86428
50+
```
51+
52+
The output of `go-server` can be found from 'dist/darwin_amd64/release/go-server.log'.
53+
54+
3. **Run client**
55+
56+
```bash
57+
cd attachment/client
58+
make -f ../../build/Makefile run
59+
```
60+
61+
Once the following messages outputs, the `go-client` calls the `go-server` successfully.
62+
63+
```bash
64+
> Buiding application binary: dist/darwin_amd64/release/go-client
65+
> Running application go-client, output is redirected to dist/darwin_amd64/release/go-client.log
66+
...
67+
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}
68+
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>
69+
response result: &{A001 Alex Stocks 18 2020-10-27 14:51:37.52 +0800 CST}
70+
```
71+
72+
3. **Integration test**
73+
dubbo-go-samples is designed to serve the purposes of not only the showcases 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:
74+
75+
```bash
76+
cd attachment/server
77+
make -f ../../build/Makefile integration
78+
```
79+
80+
Once the following messages outputs, the integration tests pass.
81+
82+
```bash
83+
> Running integration test for application go-server
84+
...
85+
--- PASS: TestGetUser (0.00s)
86+
PASS
87+
ok github.com/apache/dubbo-go-samples/attachment/go-server/tests/integration 3.603s
88+
```
89+
90+
4. **Shutdown and cleanup**
91+
```bash
92+
cd attachment/server
93+
make -f ../../build/Makefile clean docker-down
94+
```
95+
96+
*The following two ways are all relevant to IDE. Intellij GoLand is discussed here as an example.*
97+
98+
### 2. Quick start in IDE
99+
100+
Once open this project in GoLand, a list of pre-configured configures for both server and client can be found from "Run Configuration" pop up menu, for example: "helloworld-go-server" and "helloworld-go-client".
101+
102+
![run-configuration.png](.images/run-configurations.png)
103+
104+
Feel free to pick one among them to run instantly. Of course a service register server is required otherwise the samples cannot run successfully. You may consider to either manually boot up the required register server, or use the provided "docker-compose.yml" to boot it in docker environment, from the following [section](#3-manually-run-in-ide) where you can find more details.
105+
106+
### 3. Manually run in IDE
107+
108+
After open dubbo-go-samples in GoLand, follow the steps below to run/debug this
109+
example:
110+
111+
1. **Start up zookeeper server**
112+
113+
Open "attachment/go-server/docker/docker-compose.yaml", and click ▶︎▶︎ icon in the gutter on the left side of the
114+
editor, then "Services" tab should pop up and shows the similar message below:
115+
```
116+
Deploying 'Compose: docker'...
117+
/usr/local/bin/docker-compose -f .../dubbo-go-samples/attachment/go-server/docker/docker-compose.yml up -d
118+
Creating network "docker_default" with the default driver
119+
Creating docker_zookeeper_1 ...
120+
'Compose: docker' has been deployed successfully.
121+
```
122+
123+
2. **Start up service provider**
124+
125+
Open "attachment/go-server/cmd/server.go", and click ▶︎ icon just besides "main" function in the gutter on the left
126+
side, and select "Modify Run Configuration..." from the pop-up menu. Then make sure the following configs configured
127+
correctly:
128+
* Working Directory: the absolute path to "attachment/go-server", for examples: *
129+
/home/dubbo-go-samples/attachment/go-server*
130+
* Environment: CONF_PROVIDER_FILE_PATH=conf/server.yml, optionally you could also specify logging configuration
131+
with "APP_LOG_CONF_FILE=conf/log.yml"
132+
133+
Then the sample server is ready to run.
134+
135+
3. **Run service consumer**
136+
137+
Open "attachment/go-client/cmd/client.go", and click ▶︎ icon just besides "main" function in the gutter on the left
138+
side, and select "Modify Run Configuration..." from the pop-up menu. Then make sure the following configs configured
139+
correctly:
140+
* Working Directory: the absolute path to "attachment/go-client", for examples: *
141+
/home/dubbo-go-samples/attachment/go-client*
142+
* Environment: CONF_CONSUMER_FILE_PATH=conf/client.yml, optionally you could also specify logging configuration
143+
with "APP_LOG_CONF_FILE=conf/log.yml"
144+
145+
Then run it to call the remote service, you will observe the following message output:
146+
```
147+
[2021-02-03/16:19:30 main.main: client.go: 66] response result: &{A001 Alex Stocks 18 2020-02-04 16:19:30.422 +0800 CST}
148+
```
149+
150+
If you need to debug either the samples or dubbo-go, you may consider switch to **Debug** instead of **Run** in GoLand. To stop, simply click ◼︎ to shutdown everything.
151+

0 commit comments

Comments
 (0)