A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
a11::service::SessionWithRecv Class Referencefinal

A Session variant that buffers inbound messages for pull-style reception. More...

#include <cpp/a11/service/session.h>

Inheritance diagram for a11::service::SessionWithRecv:
[legend]

Classes

struct  ReceiveState
 

Public Member Functions

a11::Future< std::optional< ReceivedSessionMessage > > ReceiveWithStreamId (absl::Time deadline=absl::InfiniteFuture())
 Await the next inbound message together with its stream id.
 
a11::Future< std::optional< data::WireMessage > > Receive (absl::Time deadline=absl::InfiniteFuture())
 Await the next inbound wire message.
 
absl::Status Abort (absl::Status status) override
 Abort the session, also failing any pending receivers.
 
- Public Member Functions inherited from a11::service::Session
virtual ~Session ()=default
 
absl::StatusOr< std::vector< std::pair< std::string, std::shared_ptr< net::WireStream > > > > Streams () const
 Return the streams currently attached to the session.
 
absl::StatusOr< std::shared_ptr< net::WireStream > > GetStream (std::string_view stream_id) const
 Look up an attached stream by id.
 
std::string GetId () const
 Return the session's unique identifier.
 
std::shared_ptr< nodes::NodeMapGetNodeMap () const
 Return the NodeMap backing this session's node state.
 
absl::Status SetNodeMap (std::shared_ptr< nodes::NodeMap > node_map)
 Replace the NodeMap backing this session's node state.
 
std::shared_ptr< actions::ActionRegistryGetActionRegistry () const
 Return the registry used to resolve incoming action messages.
 
absl::Status SetActionRegistry (std::shared_ptr< actions::ActionRegistry > registry)
 Replace the registry used to resolve incoming action messages.
 
std::vector< std::pair< std::string, std::shared_ptr< actions::Action > > > Actions () const
 Return the actions currently running in the session.
 
absl::StatusOr< std::shared_ptr< actions::Action > > GetAction (std::string_view action_id) const
 Look up a running action by id.
 
absl::Status CancelAction (std::string_view action_id)
 Request cancellation of a running action.
 
absl::Status CancelAllActions ()
 Request cancellation of every running action.
 
a11::Task AwaitAllActions (absl::Duration timeout=absl::InfiniteDuration())
 Wait for all in-flight actions to finish.
 
a11::Future< std::uint32_t > DispatchNodeFragment (data::NodeFragment fragment)
 Dispatch a node fragment into the session's NodeMap.
 
a11::Task DispatchActionMessage (data::ActionMessage message, std::shared_ptr< net::WireStream > origin_stream=nullptr)
 Resolve an action message against the registry and run it.
 
a11::Task DispatchAction (std::shared_ptr< actions::Action > action)
 Run an already-constructed action within the session.
 
a11::Task DispatchWireMessage (data::WireMessage message, std::shared_ptr< net::WireStream > origin_stream=nullptr)
 Route a wire message through the session as if it arrived on a stream.
 
bool IsClosed () const
 Report whether the session has been closed.
 
bool IsDone () const
 Report whether the session has fully finished.
 
a11::Task Done () const
 Await the session's full completion.
 
absl::Status GetStatus () const
 Return the session's terminal status.
 
absl::StatusOr< a11::TaskAddStream (std::shared_ptr< net::WireStream > stream, StreamMode mode=StreamMode::kStart)
 Attach a wire stream and begin pumping its messages.
 
absl::Status HalfClose ()
 Signal that this side will send no more messages.
 
absl::Status Send (data::WireMessage message, std::string_view stream_id={})
 Enqueue a wire message for delivery.
 
absl::Time deadline () const
 Return the absolute deadline after which the session is aborted.
 
absl::Status SetDeadline (absl::Time deadline=absl::InfiniteFuture())
 Set the absolute deadline after which the session is aborted.
 

Static Public Member Functions

static absl::StatusOr< std::shared_ptr< SessionWithRecv > > Create (std::string session_id={}, data::ByteMap headers={}, SessionOptions options={}, std::shared_ptr< nodes::NodeMap > node_map=nullptr, std::shared_ptr< actions::ActionRegistry > action_registry=nullptr)
 Create a pull-style session.
 
- Static Public Member Functions inherited from a11::service::Session
static absl::StatusOr< std::shared_ptr< Session > > Create (std::string session_id={}, OnSessionStreamMessage on_stream_message={}, OnSessionStreamDone on_stream_done={}, data::ByteMap headers={}, SessionOptions options={}, std::shared_ptr< nodes::NodeMap > node_map=nullptr, std::shared_ptr< actions::ActionRegistry > action_registry=nullptr)
 Create a session.
 

Additional Inherited Members

- Protected Member Functions inherited from a11::service::Session
 Session ()=default
 
absl::Status Initialize (const std::shared_ptr< Session > &self, std::string session_id, OnSessionStreamMessage on_stream_message, OnSessionStreamDone on_stream_done, data::ByteMap headers, SessionOptions options, std::shared_ptr< nodes::NodeMap > node_map, std::shared_ptr< actions::ActionRegistry > action_registry)
 

Detailed Description

A Session variant that buffers inbound messages for pull-style reception.

Instead of delivering messages through callbacks, this session buffers them so the caller can await them explicitly via Receive() / ReceiveWithStreamId(). Suits agents that consume messages in their own loop.

Member Function Documentation

◆ Abort()

absl::Status a11::service::SessionWithRecv::Abort ( absl::Status  status)
overridevirtual

Abort the session, also failing any pending receivers.

Parameters
statusThe error to abort with.
Returns
OK, or an error status on failure.

Reimplemented from a11::service::Session.

◆ Create()

absl::StatusOr< std::shared_ptr< SessionWithRecv > > a11::service::SessionWithRecv::Create ( std::string  session_id = {},
data::ByteMap  headers = {},
SessionOptions  options = {},
std::shared_ptr< nodes::NodeMap node_map = nullptr,
std::shared_ptr< actions::ActionRegistry action_registry = nullptr 
)
static

Create a pull-style session.

Parameters
session_idUnique identifier; generated when empty.
headersSession-level headers.
optionsLimits and timeouts governing the session.
node_mapNode registry backing the session; a fresh one is created when null.
action_registryRegistry resolving incoming action messages; may be null.
Returns
The new session, or an error status on failure.

◆ Receive()

a11::Future< std::optional< data::WireMessage > > a11::service::SessionWithRecv::Receive ( absl::Time  deadline = absl::InfiniteFuture())

Await the next inbound wire message.

Parameters
deadlineAbsolute time to stop waiting.
Returns
An awaitable resolving to the next message, or nullopt when the session finishes.

◆ ReceiveWithStreamId()

a11::Future< std::optional< ReceivedSessionMessage > > a11::service::SessionWithRecv::ReceiveWithStreamId ( absl::Time  deadline = absl::InfiniteFuture())

Await the next inbound message together with its stream id.

Parameters
deadlineAbsolute time to stop waiting.
Returns
An awaitable resolving to the next message and its stream id, or nullopt when the session finishes.

The documentation for this class was generated from the following files: