Non-templated base class for outbound RPC handles (Writer and UnaryWriter).
Keeping WriterBase non-templated ensures that is_closed(), Cancel(), move-assignment, destruction, and packet reservation helpers are compiled once and shared across all writer types.
Public Member Functions | |
| WriterBase (const WriterBase &)=delete | |
| WriterBase & | operator= (const WriterBase &)=delete |
| bool | is_closed () const |
| void | Cancel () |
Protected Types | |
| enum | OnDestroy : bool { kFinishOnDestroy = false , kErrorOnDestroy = true } |
Protected Member Functions | |
| WriterBase (const IntrusivePtr< Call > &call, OnDestroy on_destroy) | |
| WriterBase (IntrusivePtr< Call > &&call, OnDestroy on_destroy) | |
| WriterBase (WriterBase &&) noexcept=default | |
| WriterBase & | operator= (WriterBase &&other) noexcept |
| size_t | payload_limit () const |
| ReserveWriteFuture | ReserveMessage (size_t max_message_size) const |
| ReserveWriteFuture | ReserveStreamEnd () const |
| ReserveWriteFuture | ReserveResponse (size_t max_message_size) const |
|
protected |
What destroying a writer before it is finished does to the call.
Writer ends its stream normally, since a stream may legitimately be empty. UnaryWriter ends the call with an error (ProtocolError::kDroppedWithoutResponse), since the peer is owed exactly one response.
|
inline |
Aborts the call immediately, closing this writer and sending kCancelled to the peer.
Unlike Finish(), which indicates normal completion of the stream or RPC, Cancel() terminates the RPC in both directions. The peer's pending or next read fails with kCancelled, and so does this end's: the call completes locally with kCancelled, so a client's Reader or response future resolves instead of waiting for a server that will not answer. A write still in flight is rejected rather than sent.
|
inline |
Returns true if no further writes can be initiated through this writer.
This becomes true once Finish() (or ReserveFinish()) is called, Cancel() is called, the peer cancels or finishes the call, or the connection closes. Server handlers can check is_closed() between async steps to stop work early if the client has disconnected or cancelled.
|
inlineprotected |
The largest payload a message or response packet on this call can carry, or 0 if the call cannot write.