The *Connection object for AsyncReader.
Applications should have little need to use this class directly. They should use AsyncReader instead, which provides an easier to use interface.
In tests, this class can be used to mock the behavior of AsyncReader.
Functions
Cancel()
Cancels the current download.
| Returns | |
|---|---|
| Type | Description |
void |
|
Read()
Asks for more data.
An outcome with a Status indicates that no more data is available. Calling Read() after it returns a Status results in undefined behavior.
Applications should not have more than one Read() pending at a time. Calling Read() while a previous Read() is pending results in undefined behavior.
Applications should not destruct an AsyncReaderConnection until a call to Read() returns a Status response.
Retrieving more data can result in three outcomes:
- Additional data (a
ReadPayload) is available: in this case the future is satisfied with aReadResponsecontaining aReadPayload. - The download is interrupted with an error: in this case the future is satisfied with a
ReadResponsecontaining aStatusthat describes the error. - The download has completed successfully: in this case the future is satisfied with a
ReadResponsecontaining an OKStatus.
A StatusOr<> cannot represent the last bullet point, so we need an absl::variant<> in this case. We could have used StatusOr<absl::optional<ReadPayload>> but that sounds unnecessarily complicated.
| Returns | |
|---|---|
| Type | Description |
future< ReadResponse > |
|
GetRequestMetadata()
Return the request metadata.
| Returns | |
|---|---|
| Type | Description |
RpcMetadata |
|
Type Aliases
ReadResponse
absl::variant< ReadPayload, Status >
The value returned by Read(). See the function for more details.