17#ifndef A11_NET_IN_PROCESS_WIRE_STREAM_H_
18#define A11_NET_IN_PROCESS_WIRE_STREAM_H_
25#include <absl/base/nullability.h>
26#include <absl/status/status.h>
27#include <absl/status/statusor.h>
28#include <absl/time/time.h>
48 struct ConstructorToken {};
52 using Pair = std::pair<std::shared_ptr<InProcessWireStream>,
53 std::shared_ptr<InProcessWireStream>>;
68 std::optional<WireStreamOptions> options = std::nullopt,
69 std::optional<WireStreamOptions>
first_options = std::nullopt,
83 absl::Status
Abort(absl::Status status)
override;
97 : state_(std::
move(state)) {}
101 static void Sender(std::shared_ptr<State> state);
102 static void Receiver(std::shared_ptr<State> state);
103 static void WatchTiming(std::shared_ptr<State> state);
104 static void MarkActivity(
const std::shared_ptr<State>&
first,
105 const std::shared_ptr<State>&
second);
106 static bool ForceAbort(
const std::shared_ptr<State>& state,
107 absl::Status status);
108 static void MaybeFinish(
const std::shared_ptr<State>& state);
109 static void Finish(
const std::shared_ptr<State>& state);
111 std::shared_ptr<State> state_;
A WireStream endpoint wired directly to a peer in the same process.
Definition in_process_wire_stream.h:44
~InProcessWireStream() override=default
absl::Status Send(data::WireMessage message) override
Enqueue a message for delivery to the peer.
Definition in_process_wire_stream.cc:163
std::pair< std::shared_ptr< InProcessWireStream >, std::shared_ptr< InProcessWireStream > > Pair
A connected pair of endpoints returned by CreatePair().
Definition in_process_wire_stream.h:53
absl::Status Abort(absl::Status status) override
Abort the stream, discarding buffered work.
Definition in_process_wire_stream.cc:315
std::string GetId() const override
Definition in_process_wire_stream.cc:390
a11::Task Done() const
Definition in_process_wire_stream.cc:361
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
static absl::StatusOr< Pair > CreatePair(std::optional< WireStreamOptions > options=std::nullopt, std::optional< WireStreamOptions > first_options=std::nullopt, std::optional< WireStreamOptions > second_options=std::nullopt, std::string preassigned_id={})
Creates a connected pair of in-process endpoints.
Definition in_process_wire_stream.cc:120
a11::Task Accept(OnMessage on_message, OnDone on_done) override
Begin the stream as the accepting ("accept") side.
Definition in_process_wire_stream.cc:233
a11::Task DrainOutgoingMessages() override
Await delivery of all buffered outbound messages.
Definition in_process_wire_stream.cc:300
std::optional< data::ByteMap > GetTrailers() const override
Definition in_process_wire_stream.cc:385
absl::Time deadline() const override
Definition in_process_wire_stream.cc:365
void *absl_nullable GetImpl() const override
Definition in_process_wire_stream.cc:394
a11::Task Start(OnMessage on_message, OnDone on_done) override
Begin the stream as the initiating ("start") side.
Definition in_process_wire_stream.cc:229
InProcessWireStream(ConstructorToken, std::shared_ptr< State > state)
Definition in_process_wire_stream.h:96
absl::Status GetStatus() const override
Definition in_process_wire_stream.cc:370
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 in_process_wire_stream.cc:70
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...