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

Namespaces

namespace  actions
 
namespace  data
 
namespace  internal
 
namespace  net
 
namespace  nodes
 
namespace  obs
 
namespace  service
 
namespace  stores
 

Classes

class  Future
 Shared handle to one asynchronous result. More...
 
class  Promise
 Move-only producer for a Future result. More...
 
struct  Unit
 Empty success value used by Future<Unit> operations that return no data. More...
 

Typedefs

using Task = Future< Unit >
 Asynchronous operation whose only successful result is completion itself.
 
using Duration = absl::Duration
 A11 duration; an alias of absl::Duration (nanosecond-aware).
 
using Time = absl::Time
 A11 instant; an alias of absl::Time (nanosecond-aware).
 

Functions

void Schedule (absl::AnyInvocable< void() && > work, thread::TreeOptions tree_options={})
 Schedule work on A11's fiber pool without returning a completion handle.
 
std::function< void()> ScheduleCancelable (absl::AnyInvocable< void() && > work, thread::TreeOptions tree_options={})
 Schedule work and return an idempotent cooperative-cancellation function.
 
template<typename T >
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.
 
template<typename T >
Future< TSubmit (absl::AnyInvocable< absl::StatusOr< T >() && > work, thread::TreeOptions tree_options)
 Run status-returning work on the fiber pool and expose its Future.
 
Task SubmitTask (absl::AnyInvocable< absl::Status() && > work, thread::TreeOptions tree_options={})
 Run an operation that returns only a completion status.
 
template<typename T >
Future< TReadyFuture (T value)
 Return an already-successful future containing value.
 
template<typename T >
Future< TCompletedFuture (absl::StatusOr< T > result)
 Return an already-completed future containing result.
 
template<typename T >
Future< TFailedFuture (absl::Status status)
 Return an already-failed future containing status.
 
Task ReadyTask ()
 Return an already-successful Task.
 
Task FailedTask (absl::Status status)
 Return an already-failed Task.
 
absl::StatusCode StatusCodeFromHttp (int http_code)
 Maps an HTTP status code to a canonical status code.
 
int StatusCodeToHttp (absl::StatusCode code)
 Maps a canonical status code to its HTTP status code.
 
absl::StatusCode StatusCodeFromWebSocket (std::uint16_t close_code)
 Maps a WebSocket close code to a canonical status code.
 
std::uint16_t StatusCodeToWebSocket (absl::StatusCode code)
 Maps a canonical status code to its WebSocket close code.
 
absl::Status MakeStatus (absl::StatusCode code, std::string message, nlohmann::json details)
 Builds a status carrying an A11 structured-details payload.
 
nlohmann::json StatusDetails (const absl::Status &status)
 Extracts the structured-details payload from a status.
 
absl::StatusOr< nlohmann::json > StatusToJson (const absl::Status &status)
 Serializes a status (code, message, details) to JSON.
 
absl::StatusOr< absl::Status > StatusFromJson (const nlohmann::json &value)
 Reconstructs a status from its JSON representation.
 
Duration ZeroDuration ()
 Returns the zero duration.
 
Duration InfiniteDuration ()
 Returns the duration greater than every finite duration.
 
Time Now ()
 Returns the current wall-clock time from Abseil's clock.
 
Time InfiniteFuture ()
 Returns the instant later than every finite time.
 
Time InfinitePast ()
 Returns the instant earlier than every finite time.
 
absl::StatusOr< std::int64_t > DurationNanoseconds (Duration duration)
 Converts a duration to whole nanoseconds.
 
absl::StatusOr< std::int64_t > TimeNanosecondsSinceEpoch (Time time)
 Converts an instant to nanoseconds since the Unix epoch.
 

Variables

constexpr std::string_view kStatusDetailsPayloadUrl
 Type URL identifying A11's status-details payload.
 

Typedef Documentation

◆ Duration

using a11::Duration = typedef absl::Duration

A11 duration; an alias of absl::Duration (nanosecond-aware).

◆ Task

Asynchronous operation whose only successful result is completion itself.

◆ Time

using a11::Time = typedef absl::Time

A11 instant; an alias of absl::Time (nanosecond-aware).

Function Documentation

◆ CompletedFuture()

template<typename T >
Future< T > a11::CompletedFuture ( absl::StatusOr< T result)

Return an already-completed future containing result.

◆ DurationNanoseconds()

absl::StatusOr< std::int64_t > a11::DurationNanoseconds ( Duration  duration)

Converts a duration to whole nanoseconds.

Parameters
durationDuration to convert.
Returns
The nanosecond count, or an error status when duration is infinite and therefore not representable.

◆ FailedFuture()

template<typename T >
Future< T > a11::FailedFuture ( absl::Status  status)

Return an already-failed future containing status.

◆ FailedTask()

Task a11::FailedTask ( absl::Status  status)
inline

Return an already-failed Task.

◆ InfiniteDuration()

Duration a11::InfiniteDuration ( )

Returns the duration greater than every finite duration.

◆ InfiniteFuture()

Time a11::InfiniteFuture ( )

Returns the instant later than every finite time.

◆ InfinitePast()

Time a11::InfinitePast ( )

Returns the instant earlier than every finite time.

◆ MakeStatus()

absl::Status a11::MakeStatus ( absl::StatusCode  code,
std::string  message,
nlohmann::json  details 
)

Builds a status carrying an A11 structured-details payload.

The details JSON is attached to the returned absl::Status so it survives the JSON and MessagePack bridges used across the wire.

Parameters
codeCanonical status code (use kOk for success).
messageHuman-readable message.
detailsArbitrary structured detail payload.
Returns
A status combining code, message and details.

◆ Now()

Time a11::Now ( )

Returns the current wall-clock time from Abseil's clock.

◆ ReadyFuture()

template<typename T >
Future< T > a11::ReadyFuture ( T  value)

Return an already-successful future containing value.

◆ ReadyTask()

Task a11::ReadyTask ( )
inline

Return an already-successful Task.

◆ Schedule()

void a11::Schedule ( absl::AnyInvocable< void() && >  work,
thread::TreeOptions  tree_options = {} 
)

Schedule work on A11's fiber pool without returning a completion handle.

Work may await another A11 Future without consuming an OS worker thread.

◆ ScheduleCancelable()

std::function< void()> a11::ScheduleCancelable ( absl::AnyInvocable< void() && >  work,
thread::TreeOptions  tree_options = {} 
)

Schedule work and return an idempotent cooperative-cancellation function.

The scheduler retains the root fiber until it has been joined.

◆ StatusCodeFromHttp()

absl::StatusCode a11::StatusCodeFromHttp ( int  http_code)

Maps an HTTP status code to a canonical status code.

Parameters
http_codeHTTP status code.
Returns
The corresponding absl::StatusCode; unknown codes map to kUnknown rather than an invented status.

◆ StatusCodeFromWebSocket()

absl::StatusCode a11::StatusCodeFromWebSocket ( std::uint16_t  close_code)

Maps a WebSocket close code to a canonical status code.

Parameters
close_codeWebSocket close code.
Returns
The corresponding absl::StatusCode; unknown codes map to kUnknown.

◆ StatusCodeToHttp()

int a11::StatusCodeToHttp ( absl::StatusCode  code)

Maps a canonical status code to its HTTP status code.

Parameters
codeCanonical status code.
Returns
The corresponding HTTP status code.

◆ StatusCodeToWebSocket()

std::uint16_t a11::StatusCodeToWebSocket ( absl::StatusCode  code)

Maps a canonical status code to its WebSocket close code.

Parameters
codeCanonical status code.
Returns
The corresponding WebSocket close code.

◆ StatusDetails()

nlohmann::json a11::StatusDetails ( const absl::Status &  status)

Extracts the structured-details payload from a status.

Parameters
statusStatus to inspect.
Returns
The attached details JSON, or a null/empty value when none is set.

◆ StatusFromJson()

absl::StatusOr< absl::Status > a11::StatusFromJson ( const nlohmann::json &  value)

Reconstructs a status from its JSON representation.

Parameters
valueJSON produced by StatusToJson.
Returns
The reconstructed status, or an error status when value is not a valid Status document.

◆ StatusToJson()

absl::StatusOr< nlohmann::json > a11::StatusToJson ( const absl::Status &  status)

Serializes a status (code, message, details) to JSON.

Parameters
statusStatus to serialize.
Returns
The JSON representation, or an error status on failure.

◆ Submit()

template<typename T >
Future< T > a11::Submit ( absl::AnyInvocable< absl::StatusOr< T >() && >  work,
thread::TreeOptions  tree_options 
)

Run status-returning work on the fiber pool and expose its Future.

◆ SubmitTask()

Task a11::SubmitTask ( absl::AnyInvocable< absl::Status() && >  work,
thread::TreeOptions  tree_options = {} 
)
inline

Run an operation that returns only a completion status.

◆ SubmitWithCancellationHook()

template<typename T >
Future< T > a11::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.

The returned Future requests both cancellation_hook and cancellation of the scheduled fiber when Future::Cancel() is called. Use this for operations that must also interrupt an external SDK or transport; ordinary cooperative A11 work can use Submit(). Cancellation remains a request, so consumers must still observe the Future's eventual result.

◆ TimeNanosecondsSinceEpoch()

absl::StatusOr< std::int64_t > a11::TimeNanosecondsSinceEpoch ( Time  time)

Converts an instant to nanoseconds since the Unix epoch.

Parameters
timeInstant to convert.
Returns
The nanoseconds since epoch, or an error status when time is infinite and therefore not representable.

◆ ZeroDuration()

Duration a11::ZeroDuration ( )

Returns the zero duration.

Variable Documentation

◆ kStatusDetailsPayloadUrl

constexpr std::string_view a11::kStatusDetailsPayloadUrl
constexpr
Initial value:
=
"type.a11.dev/status-details+json"

Type URL identifying A11's status-details payload.