Skip to content

Commit

Permalink
feature: Optimized pubsub api demo (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
codedededi authored May 26, 2022
1 parent 32d5cd6 commit 57d44ac
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 171 deletions.
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:
```shell
cd ${project_path}/demo/pubsub/server/
// 1. start subscriber
go build -o subscriber
/.subscriber -s pub_subs_demo

// 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 -s pub_subs_demo

```
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 pub_subs_demo
```
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 pub_subs_demo
```

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 pub_subs_demo
```
打印出如下信息则代表启动成功:

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 pub_subs_demo
```

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

0 comments on commit 57d44ac

Please sign in to comment.