|
A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
|
What the process running a flow knows and the language does not. More...
#include <cpp/a11/flow/values.h>
Public Member Functions | |
| virtual | ~HostBridge ()=default |
| virtual absl::StatusOr< Value > | Coerce (std::string_view tag, const Value &value)=0 |
Make value a value of the type tag names. | |
| virtual absl::StatusOr< Value > | FromChunk (const data::Chunk &chunk)=0 |
The value chunk holds. | |
| virtual absl::StatusOr< data::Chunk > | ToChunk (const Value &value, std::string_view mimetype)=0 |
A chunk holding value, in mimetype when one is asked for. | |
| virtual std::vector< absl::StatusOr< Value > > | FromChunks (absl::Span< const data::Chunk *const > chunks) |
| The values a batch of chunks holds, in order, each with its own outcome. | |
| virtual std::vector< absl::StatusOr< data::Chunk > > | ToChunks (absl::Span< const Value *const > values, std::string_view mimetype) |
Chunks holding values, in order, each with its own outcome. | |
| virtual absl::StatusOr< Value > | Adopt (const DtoPlan &shape, const Program &program, const Value &value) |
| How this host would rather hold a value of a shape the language declared. | |
What the process running a flow knows and the language does not.
Three questions, all of them about types a serialisation registry has been told about: make a value one of them, read one out of a chunk, and write one into a chunk. The Python bindings answer them against the Python registry – which is where a pydantic model actually lives – and the standalone tool answers them with the C++ registry, so the same runtime drives both without either being the special case.
|
virtualdefault |
|
inlinevirtual |
How this host would rather hold a value of a shape the language declared.
Called with a value that has already been validated against shape – defaults filled, bounds checked, nested shapes coerced – so this is about presentation and nothing else. The default is to hand it back unchanged, which is what a host with no opinion wants; the Python bindings build the pydantic model the shape describes and wrap an instance of it, so a value on a struct-typed port arrives in Python as a real model.
Validation stays on this side of the boundary on purpose: there is one implementation of what a shape means, and a host that disagreed with it would be a second, quieter one. program is there because a shape is not much use without the shapes it names: a host building a type from shape needs the ones its fields refer to, and looking them up again on the other side of the boundary would be a second trip for data this side already has.
|
pure virtual |
Make value a value of the type tag names.
tag is a dotted registry tag or a quoted mimetype: the built-in names are the language's own and are coerced before this is reached.
|
pure virtual |
The value chunk holds.
|
inlinevirtual |
The values a batch of chunks holds, in order, each with its own outcome.
Why a batch is its own question. Crossing into a host is not free per crossing: the Python bridge takes the GIL, which a flow's fiber competes for with the interpreter thread that dispatched it, and that – not the decoding – is what a value through a stage costs. A pipeline usually has several values in hand at once, so it asks once for all of them.
Per-value statuses rather than one for the batch, because the values before a bad one are still values: a reader that would have seen three of five and then a failure sees exactly that.
The default asks one at a time, so a host need not implement it.
|
pure virtual |
A chunk holding value, in mimetype when one is asked for.
|
inlinevirtual |
Chunks holding values, in order, each with its own outcome.
The writing counterpart of [FromChunks]; the same reasoning applies.