Skip to content

Commit

Permalink
docs: add java-demo to english doc (mosn#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
it-linnan committed Oct 15, 2022
1 parent 6ad3dbf commit 97db8db
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 5 deletions.
47 changes: 46 additions & 1 deletion docs/en/start/configuration/start-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ After success, a new layotto file will be generated in the directory. Let's run
>
> In this case, you can try other demos, such as [the etcd demo](en/start/configuration/start.md)
## Step 3. Run the client demo
## Step 3. Run the client demo
<!-- tabs:start -->
### **Go**

The client demo calls Layotto to add, delete, modify, and query configuration

Expand All @@ -68,6 +70,49 @@ write start
receive subscribe resp store_name:"config_demo" app_id:"apollo" items:<key:"heihei" content:"heihei1" group:"application" label:"prod" tags:<key:"feature" value:"haha" > tags:<key:"release" value:"16" > >
```

### **Java**

Download java sdk and examples:

```shell @if.not.exist java-sdk
git clone https://github.com/layotto/java-sdk
```

After downloading the project code to the local, switch the code directory:

```shell
cd java-sdk
```

Build and run the demo:

```shell
mvn -f examples-configuration/pom.xml clean package
java -jar examples-configuration/target/examples-configuration-jar-with-dependencies.jar
```

If the following information is printed, the demo is successful:

```bash
2022-10-10 21:32:03 INFO Configuration - save key success
2022-10-10 21:32:05 INFO Configuration - get configuration key1 = value1
2022-10-10 21:32:05 INFO Configuration - get configuration haha = heihei
2022-10-10 21:32:05 INFO Configuration - delete keys success
2022-10-10 21:32:07 INFO Configuration - get configuration key1 = value1
2022-10-10 21:32:09 INFO Configuration - receive subscribe heihei = heihei0
2022-10-10 21:32:11 INFO Configuration - receive subscribe heihei = heihei1
2022-10-10 21:32:13 INFO Configuration - receive subscribe heihei = heihei3
2022-10-10 21:32:15 INFO Configuration - receive subscribe heihei = heihei5
2022-10-10 21:32:17 INFO Configuration - receive subscribe heihei = heihei6
2022-10-10 21:32:19 INFO Configuration - receive subscribe heihei = heihei7
2022-10-10 21:32:22 INFO Configuration - receive subscribe heihei = heihei8
2022-10-10 21:32:25 INFO Configuration - receive subscribe heihei = heihei9
2022-10-10 21:32:28 INFO Configuration - receive subscribe heihei = heihei10
...
```

<!-- tabs:end -->

### Next step
#### What did this client Demo do?
The demo client program uses the golang version SDK provided by Layotto, and calls Layotto's Configuration API to add, delete, modify, and subscribe to configuration data.
Expand Down
45 changes: 45 additions & 0 deletions docs/en/start/configuration/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Run it:
<!-- tabs:end -->

## step 2. Start client APP
<!-- tabs:start -->
### **Go**

```shell
cd ${project_path}/demo/configuration/common
Expand All @@ -80,6 +82,49 @@ write start
receive subscribe resp store_name:"config_demo" app_id:"apollo" items:<key:"heihei" content:"heihei1" group:"application" label:"prod" tags:<key:"feature" value:"haha" > tags:<key:"release" value:"16" > >
```

### **Java**

Download java sdk and examples:

```shell @if.not.exist java-sdk
git clone https://github.com/layotto/java-sdk
```

After downloading the project code to the local, switch the code directory:

```shell
cd java-sdk
```

Build and run the demo:

```shell
mvn -f examples-configuration/pom.xml clean package
java -jar examples-configuration/target/examples-configuration-jar-with-dependencies.jar
```

If the following information is printed, the demo is successful:

```bash
2022-10-10 21:32:03 INFO Configuration - save key success
2022-10-10 21:32:05 INFO Configuration - get configuration key1 = value1
2022-10-10 21:32:05 INFO Configuration - get configuration haha = heihei
2022-10-10 21:32:05 INFO Configuration - delete keys success
2022-10-10 21:32:07 INFO Configuration - get configuration key1 = value1
2022-10-10 21:32:09 INFO Configuration - receive subscribe heihei = heihei0
2022-10-10 21:32:11 INFO Configuration - receive subscribe heihei = heihei1
2022-10-10 21:32:13 INFO Configuration - receive subscribe heihei = heihei3
2022-10-10 21:32:15 INFO Configuration - receive subscribe heihei = heihei5
2022-10-10 21:32:17 INFO Configuration - receive subscribe heihei = heihei6
2022-10-10 21:32:19 INFO Configuration - receive subscribe heihei = heihei7
2022-10-10 21:32:22 INFO Configuration - receive subscribe heihei = heihei8
2022-10-10 21:32:25 INFO Configuration - receive subscribe heihei = heihei9
2022-10-10 21:32:28 INFO Configuration - receive subscribe heihei = heihei10
...
```

<!-- tabs:end -->

## step 3. Stop containers and release resources
<!-- tabs:start -->
### **Docker Compose**
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/start/configuration/start-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ go build -o layotto
## 第三步:启动客户端Demo,调用Layotto增删改查
<!-- tabs:start -->
#### **Go**
### **Go**

构建、运行 go 语言 demo:

Expand All @@ -80,7 +80,7 @@ write start
receive subscribe resp store_name:"config_demo" app_id:"apollo" items:<key:"heihei" content:"heihei1" group:"application" label:"prod" tags:<key:"feature" value:"haha" > tags:<key:"release" value:"16" > >
```

#### **Java**
### **Java**

下载 java sdk 和示例代码:

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/start/configuration/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ go build -o layotto
## step 2. 启动测试demo
<!-- tabs:start -->
#### **Go**
### **Go**

构建、运行 go 语言 demo:

Expand All @@ -90,7 +90,7 @@ write start
receive subscribe resp store_name:"config_demo" app_id:"apollo" items:<key:"heihei" content:"heihei1" group:"application" label:"prod" tags:<key:"feature" value:"haha" > tags:<key:"release" value:"16" > >
```

#### **Java**
### **Java**

下载 java sdk 和示例代码:

Expand Down

0 comments on commit 97db8db

Please sign in to comment.