Skip to content

Commit

Permalink
fix: example bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Aug 10, 2022
1 parent 15ccc8f commit 6bf9fce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions example/client/multi-subscribe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ package main

import (
"log"
"time"

"github.com/amirhnajafiz/stallion"
)

func main() {
client, err := stallion.NewClient("localhost:9090")
if err != nil {
panic(err)
}

for i := 0; i < 2; i++ {
go func(j int) {
cli, er := stallion.NewClient("localhost:9090")
if er != nil {
panic(er)
log.Fatal(er)
}

cli.Subscribe("topic1", func(bytes []byte) {
Expand All @@ -26,10 +32,7 @@ func main() {
}(i)
}

client, err := stallion.NewClient("localhost:9090")
if err != nil {
panic(err)
}
time.Sleep(2 * time.Second)

client.Publish("topic1", []byte("Hello from 1"))
client.Publish("topic2", []byte("Hello from 2"))
Expand Down
2 changes: 1 addition & 1 deletion example/client/simple-publish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
fmt.Println(string(data))
})

client.Publish("snapp", []byte("Hello"))
client.Publish("topic", []byte("Hello"))

time.Sleep(3 * time.Second)
}

0 comments on commit 6bf9fce

Please sign in to comment.