Skip to content

Commit

Permalink
Merge branch 'main' into callback_ip
Browse files Browse the repository at this point in the history
  • Loading branch information
seeflood authored Jun 30, 2022
2 parents 5ef7e76 + ce71ce2 commit aae4147
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 6 deletions.
60 changes: 58 additions & 2 deletions docs/en/start/sequencer/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ Once finished, the layotto file will be generated in the directory, run it:
```shell @background
./layotto start -c ../../configs/runtime_config.json
```

<!-- tabs:end -->

### step 2. Run the client program and call Layotto to generate a unique id
<!-- tabs:start -->
#### **Go**
Build and run the golang demo:

```shell
cd ${project_path}/demo/sequencer/common/
Expand All @@ -86,6 +90,58 @@ Next id:next_id:10
Demo success!
```

#### **Java**

Download java sdk and examples:

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

```shell
cd java-sdk
```

Build the demo:

```shell @if.not.exist examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar
# build example jar
mvn -f examples-sequencer/pom.xml clean package
```

Run it:

```shell
java -jar examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar
```

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

```bash
Try to get next id.Key: examples
Next id: 1
Try to get next id.Key: examples
Next id: 2
Try to get next id.Key: examples
Next id: 3
Try to get next id.Key: examples
Next id: 4
Try to get next id.Key: examples
Next id: 5
Try to get next id.Key: examples
Next id: 6
Try to get next id.Key: examples
Next id: 7
Try to get next id.Key: examples
Next id: 8
Try to get next id.Key: examples
Next id: 9
Try to get next id.Key: examples
Next id: 10
```

<!-- tabs:end -->

### step 3. Stop containers and release resources
<!-- tabs:start -->
#### **Docker Compose**
Expand All @@ -107,9 +163,9 @@ docker rm -f etcd

### Next step
#### What does this client program do?
The demo client program uses the golang version SDK provided by Layotto, calls the Layotto Sequencer API, and generates a distributed unique, self-increasing id.
The demo client program uses the SDK provided by Layotto, calls the Layotto Sequencer API, and generates a distributed unique, self-increasing id.

The sdk is located in the `sdk` directory, and users can call the API provided by Layotto through the sdk.
The golang sdk is located in the `sdk` directory, and the java sdk is in https://github.com/layotto/java-sdk

In addition to using sdk, you can also interact with Layotto directly through grpc in any language you like.

Expand Down
42 changes: 42 additions & 0 deletions docs/en/start/state/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ The layotto file will be generated in the directory, run it:
<!-- tabs:end -->

### step 2. Run the client program, call Layotto to add, delete, modify and query
<!-- tabs:start -->
#### **Go**

Build and run the golang demo:

```shell
# open a new terminal tab
Expand All @@ -109,6 +113,44 @@ DeleteState succeeded.key:key1
DeleteState succeeded.key:key2
```

#### **Java**

Download java sdk and examples:

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

```shell
cd java-sdk
```

Build the demo:

```shell @if.not.exist examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar
# build example jar
mvn -f examples-state/pom.xml clean package
```

Run it:

```
java -jar examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar
```

The demo will print the following message:

```bash
SaveState succeeded.key:key1 , value: v11
GetState succeeded. key:key1 value:v11
DeleteState succeeded. key:key1
GetState after delete. key:key1 value:
SaveBulkState succeeded. key:key1 , key2
GetBulkState succeeded. key:key2
```

<!-- tabs:end -->

### step 3. Stop containers and release resources
<!-- tabs:start -->
#### **Docker Compose**
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

在开始之前,您需要在电脑上准备以下环境:

- Golang 1.14及以上
- Golang 1.14及以上, **或者** Java 8 、Maven 3
- Docker

如果您准备好了,可以点击左侧导航栏里的各种 Demo,开始我们的旅行!
Expand Down
65 changes: 62 additions & 3 deletions docs/zh/start/sequencer/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ go build -o layotto
```shell @background
./layotto start -c ../../configs/runtime_config.json
```

<!-- tabs:end -->

### step 2. 运行客户端程序,调用Layotto生成唯一id
<!-- tabs:start -->
#### **Go**

构建、运行 go 语言 demo:

```shell
cd ${project_path}/demo/sequencer/common/
Expand All @@ -89,6 +94,60 @@ Next id:next_id:10
Demo success!
```

#### **Java**

Download java sdk and examples:

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

切换目录:

```shell
cd java-sdk
```

构建:

```shell @if.not.exist examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar
# build example jar
mvn -f examples-sequencer/pom.xml clean package
```

运行:

```shell
java -jar examples-sequencer/target/examples-sequencer-1.1.0-jar-with-dependencies.jar
```

打印出以下信息说明运行成功:

```bash
Try to get next id.Key: examples
Next id: 1
Try to get next id.Key: examples
Next id: 2
Try to get next id.Key: examples
Next id: 3
Try to get next id.Key: examples
Next id: 4
Try to get next id.Key: examples
Next id: 5
Try to get next id.Key: examples
Next id: 6
Try to get next id.Key: examples
Next id: 7
Try to get next id.Key: examples
Next id: 8
Try to get next id.Key: examples
Next id: 9
Try to get next id.Key: examples
Next id: 10
```

<!-- tabs:end -->

### step 3.销毁容器,释放资源
<!-- tabs:start -->
#### **关闭 Docker Compose**
Expand All @@ -110,11 +169,11 @@ docker rm -f etcd

### 下一步
#### 这个客户端程序做了什么?
示例客户端程序中使用了Layotto提供的golang版本sdk,调用Layotto Sequencer API,生成分布式唯一、自增id。
示例客户端程序中使用了Layotto提供的多语言 sdk,调用Layotto Sequencer API,生成分布式唯一、自增id。

sdk位于`sdk`目录下,用户可以通过sdk调用Layotto提供的API。
go sdk位于`sdk`目录下,java sdk 在 https://github.com/layotto/java-sdk

除了使用sdk,您也可以用任何您喜欢的语言、通过grpc直接和Layotto交互。
除了使用sdk调用Layotto提供的API,您也可以用任何您喜欢的语言、通过grpc直接和Layotto交互。

其实sdk只是对grpc很薄的封装,用sdk约等于直接用grpc调。

Expand Down
45 changes: 45 additions & 0 deletions docs/zh/start/state/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ go build -o layotto
```shell @background
./layotto start -c ../../configs/config_redis.json
```

<!-- tabs:end -->

### step 2. 运行客户端程序,调用Layotto进行增删改查
<!-- tabs:start -->
#### **Go**

构建、运行 go 语言 demo:

```shell
# open a new terminal tab
Expand All @@ -108,6 +113,46 @@ DeleteState succeeded.key:key1
DeleteState succeeded.key:key2
```

#### **Java**

Download java sdk and examples:

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

切换目录:

```shell
cd java-sdk
```

构建:

```shell @if.not.exist examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar
# build example jar
mvn -f examples-state/pom.xml clean package
```

运行:

```
java -jar examples-state/target/examples-state-1.1.0-jar-with-dependencies.jar
```

打印出以下信息说明运行成功:

```bash
SaveState succeeded.key:key1 , value: v11
GetState succeeded. key:key1 value:v11
DeleteState succeeded. key:key1
GetState after delete. key:key1 value:
SaveBulkState succeeded. key:key1 , key2
GetBulkState succeeded. key:key2
```

<!-- tabs:end -->

### step 3. 销毁容器,释放资源
<!-- tabs:start -->
#### **关闭 Docker Compose**
Expand Down

0 comments on commit aae4147

Please sign in to comment.