|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
"flag"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/core/discov"
|
|
|
|
"github.com/tal-tech/go-zero/core/discov"
|
|
|
|
"github.com/tal-tech/go-zero/example/rpc/remote/stream"
|
|
|
|
"github.com/tal-tech/go-zero/example/rpc/remote/stream"
|
|
|
@ -33,22 +34,21 @@ func main() {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
done := make(chan struct{})
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
defer func() {
|
|
|
|
for {
|
|
|
|
done <- struct{}{}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
|
|
|
|
resp, err := stm.Recv()
|
|
|
|
resp, err := stm.Recv()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("=>", resp.Greet)
|
|
|
|
fmt.Println("=>", resp.Greet)
|
|
|
|
|
|
|
|
wg.Done()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
fmt.Println("<=", name)
|
|
|
|
fmt.Println("<=", name)
|
|
|
|
if err = stm.Send(&stream.StreamReq{
|
|
|
|
if err = stm.Send(&stream.StreamReq{
|
|
|
|
Name: name,
|
|
|
|
Name: name,
|
|
|
@ -57,5 +57,5 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<-done
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
}
|
|
|
|