A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
types.h File Reference

A11's core wire value types: chunks, node fragments and messages. More...

#include <optional>
#include <string>
#include <string_view>
#include <variant>
#include <vector>
#include <absl/base/nullability.h>
#include <absl/container/flat_hash_map.h>
#include <absl/status/status.h>
#include <absl/status/statusor.h>
#include <absl/time/time.h>

Go to the source code of this file.

Classes

struct  a11::data::ChunkMetadata
 Descriptive metadata attached to a a11::data::Chunk. More...
 
class  a11::data::ChunkObject
 An in-process value a chunk may carry instead of its encoded bytes. More...
 
struct  a11::data::Chunk
 A unit of data: bytes plus optional descriptive metadata. More...
 
struct  a11::data::NodeRef
 A reference to a (slice of a) logical node, in lieu of inline data. More...
 
struct  a11::data::NodeFragment
 One piece of a node's stream: an inline chunk or a node reference. More...
 
struct  a11::data::Port
 Binds an action's port name to the concrete node id serving it. More...
 
struct  a11::data::ActionMessage
 The wire description of an action invocation. More...
 
struct  a11::data::WireMessage
 The top-level frame exchanged between two A11 endpoints. More...
 

Namespaces

namespace  a11
 
namespace  a11::data
 

Typedefs

using a11::data::Bytes = std::string
 Raw byte payload; an alias of std::string.
 
using a11::data::ByteMap = absl::flat_hash_map< std::string, Bytes >
 String-keyed map of byte values (headers, attributes, etc.).
 

Functions

absl::Status a11::data::ValidateName (std::string_view name)
 Validates an A11 identifier (node/port/action name).
 
absl::StatusOr< Chunk > a11::data::MakeStatusChunk (const absl::Status &status, bool closing=false)
 Encodes status as a chunk of mimetype kStatusMimetype.
 
bool a11::data::IsStatusChunk (const Chunk &chunk)
 Whether chunk carries a packed status.
 
bool a11::data::IsCloseStatusChunk (const Chunk &chunk)
 Whether chunk is a status chunk marking write-half closure.
 
absl::StatusOr< absl::Status > a11::data::StatusFromStatusChunk (const Chunk &chunk)
 Decodes a status previously encoded by MakeStatusChunk.
 
bool a11::data::IsHalfCloseMessage (const WireMessage &message)
 Whether message is a transport half-close signal.
 
WireMessage a11::data::MakeHalfCloseMessage (ByteMap trailers={})
 Builds a half-close WireMessage carrying optional trailers.
 
size_t a11::data::EmptyWireMessageSize ()
 The encoded size of an empty WireMessage.
 

Variables

constexpr std::string_view a11::data::kStatusMimetype = "application/x-a11-status"
 Mimetype marking a chunk whose payload is a packed status.
 
constexpr std::string_view a11::data::kCloseAttribute = "a11-close"
 Metadata attribute marking a status chunk as a closure marker.
 

Detailed Description

A11's core wire value types: chunks, node fragments and messages.

These are the plain data records that A11 moves between endpoints. A a11::data::Chunk is a blob of bytes plus a a11::data::ChunkMetadata (mimetype and attributes); chunks flow through named nodes as a11::data::NodeFragment values (either an inline chunk or a a11::data::NodeRef pointing at a slice of another node). Actions are described on the wire by a11::data::ActionMessage (a named invocation with input/output a11::data::Port lists and headers), and one or more of these, together with node fragments, are batched into a a11::data::WireMessage – the unit exchanged across a stream.

Every record validates itself, reports an approximate encoded size, prints a debug string, and round-trips through MessagePack via ToMsgpack / FromMsgpack.