A WireStream endpoint wired directly to a peer in the same process.
More...
#include <cpp/a11/net/in_process_wire_stream.h>
A WireStream endpoint wired directly to a peer in the same process.
The two endpoints share in-memory queues, so a Send() on one is delivered to the OnMessage callback of the other with no network hop. One endpoint drives Start() and the other Accept(); either may HalfClose() or Abort(). Construct a connected pair with CreatePair() rather than instantiating directly.
◆ Pair
◆ ~InProcessWireStream()
| a11::net::InProcessWireStream::~InProcessWireStream |
( |
| ) |
|
|
overridedefault |
◆ InProcessWireStream()
| a11::net::InProcessWireStream::InProcessWireStream |
( |
ConstructorToken |
, |
|
|
std::shared_ptr< State > |
state |
|
) |
| |
|
inlineexplicit |
◆ Abort()
| absl::Status a11::net::InProcessWireStream::Abort |
( |
absl::Status |
status | ) |
|
|
overridevirtual |
Abort the stream, discarding buffered work.
- Parameters
-
| status | A non-OK status reported to the peer as the abort reason. |
- Returns
- OK if the abort was accepted.
Implements a11::net::WireStream.
◆ Accept()
Begin the stream as the accepting ("accept") side.
- Parameters
-
| on_message | Invoked for each inbound message (nullopt = peer half-closed). |
| on_done | Invoked once when the stream has finished. |
- Returns
- An awaitable that resolves once the stream is accepted.
Implements a11::net::WireStream.
◆ CreatePair()
Creates a connected pair of in-process endpoints.
- Parameters
-
| options | Shared WireStreamOptions applied to both endpoints. |
| first_options | Optional overrides for the first endpoint. |
| second_options | Optional overrides for the second endpoint. |
| preassigned_id | When non-empty, fixes the shared stream id (and hence the tracing trace id) instead of generating one. This is the implementation-level hook for preassigning a stream's trace id without widening the WireStream interface. |
- Returns
- The two connected endpoints, or an error status.
◆ deadline()
| absl::Time a11::net::InProcessWireStream::deadline |
( |
| ) |
const |
|
overridevirtual |
◆ Done()
| a11::Task a11::net::InProcessWireStream::Done |
( |
| ) |
const |
- Returns
- An awaitable that resolves when this endpoint has fully finished (its peer half-closed or the stream aborted).
◆ DrainOutgoingMessages()
| a11::Task a11::net::InProcessWireStream::DrainOutgoingMessages |
( |
| ) |
|
|
overridevirtual |
Await delivery of all buffered outbound messages.
- Returns
- An awaitable that resolves once this endpoint's queued messages have been flushed to the transport (requires a prior HalfClose).
Implements a11::net::WireStream.
◆ GetId()
| std::string a11::net::InProcessWireStream::GetId |
( |
| ) |
const |
|
overridevirtual |
◆ GetImpl()
- Returns
- An opaque handle to the underlying transport object (advanced; may be null).
Implements a11::net::WireStream.
◆ GetStatus()
| absl::Status a11::net::InProcessWireStream::GetStatus |
( |
| ) |
const |
|
overridevirtual |
- Returns
- The stream's terminal status (OK unless it failed or was aborted).
Implements a11::net::WireStream.
◆ GetTrailers()
| std::optional< data::ByteMap > a11::net::InProcessWireStream::GetTrailers |
( |
| ) |
const |
|
overridevirtual |
- Returns
- The peer's closing trailers, if the stream has received them.
Implements a11::net::WireStream.
◆ HalfClose() [1/3]
| absl::Status a11::net::WireStream::HalfClose |
( |
| ) |
|
|
inline |
◆ HalfClose() [2/3]
| absl::Status a11::net::InProcessWireStream::HalfClose |
( |
data::ByteMap |
trailers | ) |
|
|
overridevirtual |
Signal that this side will send no more messages.
The terminal marker is queued after buffered outbound messages and, once the peer also half-closes, the stream completes. Inbound messages continue to be delivered until then. Call DrainOutgoingMessages() to await local transport delivery.
- Parameters
-
| trailers | Optional closing metadata delivered to the peer. |
- Returns
- OK, or a non-OK status if the stream cannot be half-closed.
Implements a11::net::WireStream.
◆ HalfClose() [3/3]
Signal that this side will send no more messages.
The terminal marker is queued after buffered outbound messages and, once the peer also half-closes, the stream completes. Inbound messages continue to be delivered until then. Call DrainOutgoingMessages() to await local transport delivery.
- Parameters
-
| trailers | Optional closing metadata delivered to the peer. |
- Returns
- OK, or a non-OK status if the stream cannot be half-closed.
Implements a11::net::WireStream.
◆ Send()
Enqueue a message for delivery to the peer.
Non-blocking.
The message is admitted to this endpoint's outbound queue and delivered asynchronously by the transport task, which is also where backpressure is applied; there is no delivery-order guarantee across messages (see the class comment).
- Parameters
-
| message | The message to send. |
- Returns
- OK once the message is queued, or a non-OK status if the stream is not writable (e.g. already half-closed or aborted).
Implements a11::net::WireStream.
◆ SetDeadline() [1/3]
| absl::Status a11::net::WireStream::SetDeadline |
( |
| ) |
|
|
inline |
Clear any deadline (equivalent to an infinite deadline).
◆ SetDeadline() [2/3]
| absl::Status a11::net::InProcessWireStream::SetDeadline |
( |
absl::Time |
deadline | ) |
|
|
overridevirtual |
Set the absolute deadline after which the stream is aborted.
- Parameters
-
| deadline | The deadline; absl::InfiniteFuture() disables it. |
Implements a11::net::WireStream.
◆ SetDeadline() [3/3]
| virtual absl::Status a11::net::WireStream::SetDeadline |
( |
absl::Time |
deadline | ) |
|
|
virtual |
Set the absolute deadline after which the stream is aborted.
- Parameters
-
| deadline | The deadline; absl::InfiniteFuture() disables it. |
Implements a11::net::WireStream.
◆ Start()
Begin the stream as the initiating ("start") side.
- Parameters
-
| on_message | Invoked for each inbound message (nullopt = peer half-closed). |
| on_done | Invoked once when the stream has finished. |
- Returns
- An awaitable that resolves once the startup handshake completes.
Implements a11::net::WireStream.
The documentation for this class was generated from the following files: