15#ifndef A11_NET_WIRE_STREAM_H_
16#define A11_NET_WIRE_STREAM_H_
23#include <absl/base/nullability.h>
24#include <absl/status/status.h>
25#include <absl/time/time.h>
65 std::function<
a11::Task(std::optional<data::WireMessage> message)>;
151 virtual absl::Status
Abort(absl::Status status) = 0;
A bidirectional, message-oriented channel between two A11 endpoints.
Definition wire_stream.h:89
virtual std::optional< data::ByteMap > GetTrailers() const =0
virtual ~WireStream()=default
virtual a11::Task Accept(OnMessage on_message, OnDone on_done)=0
Begin the stream as the accepting ("accept") side.
virtual void *absl_nullable GetImpl() const =0
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
virtual a11::Task DrainOutgoingMessages()=0
Await delivery of all buffered outbound messages.
virtual absl::Status Send(data::WireMessage message)=0
Enqueue a message for delivery to the peer.
virtual absl::Status SetDeadline(absl::Time deadline)=0
Set the absolute deadline after which the stream is aborted.
virtual absl::Status HalfClose(data::ByteMap trailers)=0
Signal that this side will send no more messages.
virtual absl::Time deadline() const =0
virtual a11::Task Start(OnMessage on_message, OnDone on_done)=0
Begin the stream as the initiating ("start") side.
virtual absl::Status GetStatus() const =0
virtual absl::Status Abort(absl::Status status)=0
Abort the stream, discarding buffered work.
virtual std::string GetId() const =0
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
constexpr size_t kMaxSingleMessageSize
Hard ceiling on the size of a single reassembled inbound WireMessage.
Definition wire_stream.h:35
absl::StatusOr< data::ByteMap > NormalizeWireHeaders(data::ByteMap headers)
Validate and case-normalise a wire header map, returning the normalised copy or a non-OK status if a ...
Definition wire_stream.cc:40
constexpr std::string_view kAbortStatusHeader
Trailer key under which an aborting endpoint reports its terminal status.
Definition wire_stream.h:33
Future< Unit > Task
Asynchronous operation whose only successful result is completion itself.
Definition future.h:403
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
Buffering, sizing, and deadline limits for a WireStream endpoint.
Definition wire_stream.h:44
size_t max_single_message_size
Reject any single reassembled message larger than this.
Definition wire_stream.h:48
size_t max_buffered_incoming_messages
Maximum inbound messages buffered before backpressure is applied.
Definition wire_stream.h:46
absl::Duration message_timeout
Fail a message that cannot be delivered within this duration (infinite = no per-message timeout).
Definition wire_stream.h:53
absl::Status Validate() const
Validate the option values, returning a non-OK status if inconsistent.
Definition wire_stream.cc:16
size_t max_buffered_incoming_bytes
Maximum total bytes of buffered inbound messages.
Definition wire_stream.h:50
absl::Time deadline
Absolute deadline after which the stream is aborted.
Definition wire_stream.h:55
A11's core wire value types: chunks, node fragments and messages.