Skip to content

Commit 6d5cd14

Browse files
committed
docs: Correct manual flow control README regarding onNext blocking (#12657)
1 parent a43f387 commit 6d5cd14

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

  • examples/src/main/java/io/grpc/examples/manualflowcontrol

examples/src/main/java/io/grpc/examples/manualflowcontrol/README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
gRPC Manual Flow Control Example
2-
=====================
1+
# gRPC Manual Flow Control Example
2+
33
Flow control is relevant for streaming RPC calls.
44

55
By default, gRPC will handle dealing with flow control. However, for specific
@@ -25,14 +25,7 @@ value.
2525

2626
### Outgoing Flow Control
2727

28-
The underlying layer (such as Netty) will make the write wait when there is no
29-
space to write the next message. This causes the request stream to go into
30-
a not ready state and the outgoing onNext method invocation waits. You can
31-
explicitly check that the stream is ready for writing before calling onNext to
32-
avoid blocking. This is done with `CallStreamObserver.isReady()`. You can
33-
utilize this to start doing reads, which may allow
34-
the other side of the channel to complete a write and then to do its own reads,
35-
thereby avoiding deadlock.
28+
The underlying layer (such as Netty) manages a buffer for outgoing messages. If you write messages faster than they can be sent over the network, this buffer will grow, which can eventually lead to an OutOfMemoryError. The outgoing onNext method invocation does not block when this happens. Therefore, you should explicitly check that the stream is ready for writing via CallStreamObserver.isReady() before calling onNext to avoid buffering excessive amounts of data in memory.
3629

3730
### Incoming Manual Flow Control
3831

@@ -71,6 +64,7 @@ When you are ready to begin processing the next value from the stream call
7164
`serverCallStreamObserver.request(1)`
7265

7366
### Related documents
67+
7468
Also see [gRPC Flow Control Users Guide][user guide]
7569

76-
[user guide]: https://grpc.io/docs/guides/flow-control
70+
[user guide]: https://grpc.io/docs/guides/flow-control

0 commit comments

Comments
 (0)