A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::service Namespace Reference

Namespaces

namespace  internal
 

Classes

struct  ReceivedSessionMessage
 An inbound wire message paired with the id of the stream it arrived on. More...
 
class  Service
 A registry of actions, the sessions serving them, and their lifecycle. More...
 
struct  ServiceOptions
 How a service treats the connections it accepts. More...
 
class  Session
 A connection-scoped runtime that multiplexes wire streams and runs actions. More...
 
struct  SessionOptions
 Limits and timeouts governing a Session's buffering, concurrency, and lifetime. More...
 
class  SessionWithRecv
 A Session variant that buffers inbound messages for pull-style reception. More...
 

Typedefs

using OnServiceConnection = std::function< a11::Task(std::shared_ptr< Session >, std::shared_ptr< net::WireStream >)>
 Per-connection preparation, run before the session starts pumping.
 
using OnSessionStreamMessage = std::function< a11::Task(std::optional< data::WireMessage >, std::shared_ptr< net::WireStream >, std::shared_ptr< Session >)>
 Callback invoked for each message received on a session stream (nullopt signals end-of-stream); may be a coroutine.
 
using OnSessionStreamDone = std::function< a11::Task(std::shared_ptr< net::WireStream >, std::shared_ptr< Session >)>
 Callback invoked once a session stream has finished; may be a coroutine.
 

Enumerations

enum class  StreamMode { kStart , kAccept }
 Whether this side starts (kStart) or accepts (kAccept) a stream during its startup handshake. More...
 

Functions

template<typename StreamT >
std::function< a11::Task(std::shared_ptr< StreamT >)> AcceptInto (const std::shared_ptr< Service > &service, StreamMode mode=StreamMode::kAccept)
 A callback for any transport's on-stream hook, serving into service.
 
absl::StatusOr< data::ByteMap > NormalizeSessionHeaders (data::ByteMap headers)
 Validate and case-normalize session headers.
 

Variables

constexpr std::string_view kSessionStatusHeader = "x-a11-session-status"
 Trailer/header used to communicate the session's structured terminal status.
 
constexpr size_t kMaxSingleMessageSize = 32 * 1024 * 1024
 Hard upper bound for any one WireMessage admitted by a Session.
 

Typedef Documentation

◆ OnServiceConnection

using a11::service::OnServiceConnection = typedef std::function<a11::Task( std::shared_ptr<Session>, std::shared_ptr<net::WireStream>)>

Per-connection preparation, run before the session starts pumping.

Called once per accepted stream, after its Session exists and before AddStream, which is the only window in which a connection can be specialised without racing its first message. Both handles are passed because the useful things need both: swapping in a registry copy carrying this peer's own actions, or binding a bridge that reverse-dispatches calls back over this very stream.

A non-OK Task rejects the connection: the stream is aborted with that status and the session never runs.

◆ OnSessionStreamDone

using a11::service::OnSessionStreamDone = typedef std::function<a11::Task( std::shared_ptr<net::WireStream>, std::shared_ptr<Session>)>

Callback invoked once a session stream has finished; may be a coroutine.

◆ OnSessionStreamMessage

using a11::service::OnSessionStreamMessage = typedef std::function<a11::Task( std::optional<data::WireMessage>, std::shared_ptr<net::WireStream>, std::shared_ptr<Session>)>

Callback invoked for each message received on a session stream (nullopt signals end-of-stream); may be a coroutine.

Enumeration Type Documentation

◆ StreamMode

enum class a11::service::StreamMode
strong

Whether this side starts (kStart) or accepts (kAccept) a stream during its startup handshake.

Enumerator
kStart 
kAccept 

Function Documentation

◆ AcceptInto()

template<typename StreamT >
std::function< a11::Task(std::shared_ptr< StreamT >)> a11::service::AcceptInto ( const std::shared_ptr< Service > &  service,
StreamMode  mode = StreamMode::kAccept 
)

A callback for any transport's on-stream hook, serving into service.

Holds a weak reference, so a server that outlives its service rejects new connections instead of dereferencing a destroyed one.

AcceptInto<net::WebSocketWireStream>(service), options);
static absl::StatusOr< std::shared_ptr< WebSocketWireServer > > Create(OnWebSocketStream on_stream, WebSocketServerOptions options={})
Starts a WebSocket server accepting A11 connections.
Definition websocket_wire_stream.cc:185
Template Parameters
StreamTThe concrete stream type the transport hands out.

◆ NormalizeSessionHeaders()

absl::StatusOr< data::ByteMap > a11::service::NormalizeSessionHeaders ( data::ByteMap  headers)

Validate and case-normalize session headers.

Parameters
headersThe raw headers to normalize.
Returns
The normalized headers, or an error status if invalid.

Variable Documentation

◆ kMaxSingleMessageSize

constexpr size_t a11::service::kMaxSingleMessageSize = 32 * 1024 * 1024
inlineconstexpr

Hard upper bound for any one WireMessage admitted by a Session.

◆ kSessionStatusHeader

constexpr std::string_view a11::service::kSessionStatusHeader = "x-a11-session-status"
inlineconstexpr

Trailer/header used to communicate the session's structured terminal status.