make client concurrent
This commit is contained in:
parent
6000071bb6
commit
c0406348f6
@ -32,12 +32,17 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s := make(chan bool, 10)
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
resp, err := c.Hello(ctx, &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
|
s <- true
|
||||||
if err != nil {
|
go func(j int) {
|
||||||
fmt.Fprintf(os.Stderr, "hello: %#v\n", err)
|
resp, err := c.Hello(ctx, &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
|
||||||
os.Exit(1)
|
if err != nil {
|
||||||
}
|
fmt.Fprintf(os.Stderr, "hello: %#v\n", err)
|
||||||
fmt.Printf("0x%08x: %#v\n", i, resp)
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
fmt.Printf("0x%08x: %#v\n", j, resp)
|
||||||
|
<-s
|
||||||
|
}(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user