Skip to content

Commit

Permalink
update rpc example
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Sep 18, 2020
1 parent 0f81400 commit 974c19d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions example/rpc/client/stream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
"sync"

"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/example/rpc/remote/stream"
Expand Down Expand Up @@ -33,22 +34,21 @@ func main() {
log.Fatal(err)
}

done := make(chan struct{})
var wg sync.WaitGroup
go func() {
defer func() {
done <- struct{}{}
}()
for i := 0; i < 3; i++ {
for {
resp, err := stm.Recv()
if err != nil {
log.Fatal(err)
}

fmt.Println("=>", resp.Greet)
wg.Done()
}
}()

for i := 0; i < 3; i++ {
wg.Add(1)
fmt.Println("<=", name)
if err = stm.Send(&stream.StreamReq{
Name: name,
Expand All @@ -57,5 +57,5 @@ func main() {
}
}

<-done
wg.Wait()
}

0 comments on commit 974c19d

Please sign in to comment.