Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Optimized pubsub api demo #594

Merged
merged 10 commits into from
May 26, 2022
20 changes: 20 additions & 0 deletions demo/pubsub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
You can run server/client demo with different component names.
It is worth noting that both server and client demo should set the same store name by param `-s`.
For example:
```go
codedededi marked this conversation as resolved.
Show resolved Hide resolved
cd ${project_path}/demo/pubsub/server/
// 1. start subscriber
go build -o subscriber
/.subscriber
codedededi marked this conversation as resolved.
Show resolved Hide resolved

// 2. start layotto
cd ${project_path}/cmd/layotto
go build -o layotto
./layotto start -c ../../configs/config_in_memory.json

// 3. start publisher
cd ${project_path}/demo/pubsub/client/
go build -o publisher
./publisher
codedededi marked this conversation as resolved.
Show resolved Hide resolved

```
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func init() {

func main() {
flag.Parse()
if storeName == "" {
panic("storeName is empty.")
}
// 1. construct client
cli, err := client.NewClient()
if err != nil {
Expand Down
46 changes: 0 additions & 46 deletions demo/pubsub/in-memory/in-memory.go

This file was deleted.

47 changes: 0 additions & 47 deletions demo/pubsub/redis/client/publish_client.go

This file was deleted.

70 changes: 0 additions & 70 deletions demo/pubsub/redis/server/subscribe_server.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func init() {

func main() {
flag.Parse()
if storeName == "" {
panic("storeName is empty.")
}
// start a grpc server for callback
testSub()
}
Expand Down
8 changes: 4 additions & 4 deletions docs/en/start/pubsub/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Parameter Description:
Build:

```shell
cd ${project_path}/demo/pubsub/redis/server/
cd ${project_path}/demo/pubsub/server/
go build -o subscriber
```

Start subscriber:

```shell @background
./subscriber
./subscriber -s redis
codedededi marked this conversation as resolved.
Show resolved Hide resolved
```
If the following information is printed out, it means the startup is successful:

Expand Down Expand Up @@ -98,9 +98,9 @@ After completion, the layotto file will be generated in the directory, run it:
### Step 4. Run the Publisher program and call Layotto to publish events

```shell
cd ${project_path}/demo/pubsub/redis/client/
cd ${project_path}/demo/pubsub/client/
go build -o publisher
./publisher
./publisher -s redis
codedededi marked this conversation as resolved.
Show resolved Hide resolved
```

If the following information is printed, the call is successful:
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/start/pubsub/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ docker run -itd --name redis-test -p 6380:6379 redis

### 第二步:启动Subscriber程序,订阅事件
```shell
cd ${project_path}/demo/pubsub/redis/server/
cd ${project_path}/demo/pubsub/server/
go build -o subscriber
```

```shell @background
./subscriber
./subscriber -s redis
codedededi marked this conversation as resolved.
Show resolved Hide resolved
```
打印出如下信息则代表启动成功:

Expand Down Expand Up @@ -95,9 +95,9 @@ go build -o layotto
### 第四步:运行Publisher程序,调用Layotto发布事件

```shell
cd ${project_path}/demo/pubsub/redis/client/
cd ${project_path}/demo/pubsub/client/
go build -o publisher
./publisher
./publisher -s redis
codedededi marked this conversation as resolved.
Show resolved Hide resolved
```

打印出如下信息则代表调用成功:
Expand Down