예제 #1
0
파일: client.go 프로젝트: runningwild/repro
func doEchoStream(client simple.SimpleClient, num int) {
	log.Printf("EchoStream: %v", num)
	stream, err := client.EchoStream(context.Background())
	if err != nil {
		log.Printf("Failed EchoStream: %v", err)
		return
	}
	done := make(chan struct{})
	go func() {
		defer close(done)
		for {
			in, err := stream.Recv()
			if err == io.EOF {
				return
			}
			if err != nil {
				log.Printf("Failed EchoStream: %v", err)
				return
			}
			log.Printf("EchoStream received %v", in)
		}
	}()
	defer func() {
		stream.CloseSend()
		<-done
	}()
	for i := 0; i < num; i++ {
		if err := stream.Send(&simple.Number{Num: int32(i)}); err != nil {
			log.Printf("Failed to EchoStream: %v", err)
			return
		}
	}
}
예제 #2
0
파일: client.go 프로젝트: runningwild/repro
func doEcho(client simple.SimpleClient, num int) {
	req := &simple.Number{Num: int32(num)}
	log.Printf("Echo: %v", req)
	reply, err := client.Echo(context.Background(), req)
	if err != nil {
		log.Printf("Failed to echo: %v", err)
		return
	}
	log.Printf("Echo reply: %v", reply)
}
예제 #3
0
파일: client.go 프로젝트: runningwild/repro
func doSum(client simple.SimpleClient, num int) {
	log.Printf("Sum: %d", num)
	stream, err := client.Sum(context.Background())
	if err != nil {
		log.Printf("Failed to Sum: %v", err)
		return
	}
	for i := 0; i < num; i++ {
		if err := stream.Send(&simple.Number{Num: int32(i)}); err != nil {
			log.Printf("Failed to sum: %v", err)
			return
		}
	}
	reply, err := stream.CloseAndRecv()
	if err != nil {
		log.Printf("Failed to sum: %v", err)
		return
	}
	log.Printf("Sum up to %d: %v", num, reply)
}
예제 #4
0
파일: client.go 프로젝트: runningwild/repro
// printFeatures lists all the features within the given bounding Rectangle.
func doCount(client simple.SimpleClient, num int) {
	req := &simple.Number{Num: int32(num)}
	log.Printf("Count: %v", req)
	stream, err := client.Count(context.Background(), req)
	if err != nil {
		log.Printf("Failed to count: %v", err)
		return
	}
	for {
		reply, err := stream.Recv()
		if err == io.EOF {
			break
		}
		if err != nil {
			log.Printf("Count stream failed: %v", err)
			return
		}
		log.Printf("Count reply: %v", reply)
	}
	log.Printf("Counting complete")
}