3#ifndef A11_NET_WIRE_STREAM_WITH_RECV_H_
4#define A11_NET_WIRE_STREAM_WITH_RECV_H_
10#include <absl/base/nullability.h>
11#include <absl/status/status.h>
12#include <absl/status/statusor.h>
13#include <absl/time/time.h>
31 public std::enable_shared_from_this<WireStreamWithRecv> {
35 struct ConstructorToken {};
39 static absl::StatusOr<std::shared_ptr<WireStreamWithRecv>>
Create(
40 std::shared_ptr<WireStream> stream);
54 absl::Status
Abort(absl::Status status)
override;
68 absl::Duration
timeout = absl::InfiniteDuration());
76 std::string
id, std::shared_ptr<State> state)
77 : stream_(std::
move(stream)),
79 state_(std::
move(state)) {}
84 std::optional<data::WireMessage> message);
86 void RecordCurrentStatus()
const;
87 void SignalError(absl::Status status)
const;
89 std::shared_ptr<WireStream> stream_;
91 std::shared_ptr<State> state_;
Pull-oriented adapter for a callback-driven WireStream.
Definition wire_stream_with_recv.h:31
absl::Status SetDeadline()
Clear any deadline (equivalent to an infinite deadline).
Definition wire_stream.h:154
a11::Task DrainOutgoingMessages() override
Await delivery of all buffered outbound messages.
Definition wire_stream_with_recv.cc:128
absl::Status HalfClose()
Half-close with no trailers.
Definition wire_stream.h:125
std::shared_ptr< WireStream > wrapped_stream() const
Return the underlying callback-oriented stream.
Definition wire_stream_with_recv.h:71
absl::Status GetStatus() const override
Definition wire_stream_with_recv.cc:173
absl::Status Abort(absl::Status status) override
Abort the stream, discarding buffered work.
Definition wire_stream_with_recv.cc:139
a11::Task Accept()
Accept the wrapped stream and route inbound messages to Receive().
Definition wire_stream_with_recv.cc:90
std::optional< data::ByteMap > GetTrailers() const override
Definition wire_stream_with_recv.cc:183
void *absl_nullable GetImpl() const override
Definition wire_stream_with_recv.cc:195
a11::Task Start()
Start the wrapped stream and route inbound messages to Receive().
Definition wire_stream_with_recv.cc:86
absl::Time deadline() const override
Definition wire_stream_with_recv.cc:165
WireStreamWithRecv(ConstructorToken, std::shared_ptr< WireStream > stream, std::string id, std::shared_ptr< State > state)
Definition wire_stream_with_recv.h:75
std::string GetId() const override
Definition wire_stream_with_recv.cc:191
absl::Status Send(data::WireMessage message) override
Enqueue a message for delivery to the peer.
Definition wire_stream_with_recv.cc:68
static absl::StatusOr< std::shared_ptr< WireStreamWithRecv > > Create(std::shared_ptr< WireStream > stream)
Wrap stream, preserving its id, lifecycle, and transport handle.
Definition wire_stream_with_recv.cc:51
a11::Future< std::optional< data::WireMessage > > Receive(absl::Duration timeout=absl::InfiniteDuration())
Await one inbound message, or nullopt after the peer half-closes.
Definition wire_stream_with_recv.cc:203
A bidirectional, message-oriented channel between two A11 endpoints.
Definition wire_stream.h:89
absl::Status SetDeadline()
Clear any deadline (equivalent to an infinite deadline).
Definition wire_stream.h:154
absl::Status HalfClose()
Half-close with no trailers.
Definition wire_stream.h:125
Completion values used by every asynchronous A11 operation.
absl::flat_hash_map< std::string, Bytes > ByteMap
String-keyed map of byte values (headers, attributes, etc.).
Definition types.h:42
std::function< a11::Task(std::optional< data::WireMessage > message)> OnMessage
Called for each inbound message; std::nullopt signals the peer half-closed.
Definition wire_stream.h:65
std::function< a11::Task()> OnDone
Called once, when the stream has fully finished (cleanly or via abort).
Definition wire_stream.h:67
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30
The top-level frame exchanged between two A11 endpoints.
Definition types.h:275
Definition wire_stream_with_recv.cc:40
A11's core wire value types: chunks, node fragments and messages.
A11's transport abstraction: the bidirectional WireStream channel and the options/callbacks that driv...