Skip to content

Commit dff87b7

Browse files
authored
example: improve stream example (#110)
1 parent 4c450ff commit dff87b7

File tree

1 file changed

+3
-2
lines changed
  • examples/features/stream/client

1 file changed

+3
-2
lines changed

examples/features/stream/client/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func clientStream(ctx context.Context, proxy pb.TestStreamClientProxy) error {
8686
// Call Send to continuously send data.
8787
if err = streamClient.Send(&pb.HelloReq{Msg: fmt.Sprintf("ping : %v", i)}); err != nil {
8888
log.ErrorContextf(ctx, "ClientStream send error: %v", err)
89-
break
89+
return err
9090
}
9191
}
9292

@@ -134,7 +134,7 @@ func bidirectionalStream(ctx context.Context, proxy pb.TestStreamClientProxy) er
134134
// The client send request data to the server 5 times using a for loop.
135135
if err = streamClient.Send(&pb.HelloReq{Msg: "ping: " + strconv.Itoa(i)}); err != nil {
136136
log.ErrorContextf(ctx, "BidirectionalStream Send message error: %v", err)
137-
break
137+
return err
138138
}
139139
}
140140

@@ -153,6 +153,7 @@ func bidirectionalStream(ctx context.Context, proxy pb.TestStreamClientProxy) er
153153
}
154154
if err != nil {
155155
log.ErrorContextf(ctx, "BidirectionalStream receive error from server: %v", err)
156+
break
156157
}
157158
log.InfoContextf(ctx, "BidirectionalStream reply message is: %s", rsp.GetMsg())
158159
}

0 commit comments

Comments
 (0)