|
A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
|
A persistent, multi-process ChunkStore backed by Redis Streams. More...
#include <cpp/a11/stores/redis_chunk_store.h>
Public Member Functions | |
| ~RedisChunkStore () override=default | |
| a11::Future< data::NodeFragment > | Get (std::uint32_t seq, absl::Time deadline) override |
| Get the fragment stored at a sequence number. | |
| a11::Future< data::NodeFragment > | GetByArrivalOrder (std::uint64_t arrival_order, absl::Time deadline) override |
| Get the fragment identified by the order in which it arrived, rather than by its sequence number. | |
| a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next (absl::Time deadline, size_t limit) override |
Get up to limit fragments from the shared logical-sequence cursor. | |
| a11::Future< std::uint32_t > | Put (data::NodeFragment fragment) override |
| Append a single fragment to the log. | |
| a11::Future< std::vector< std::uint32_t > > | PutMany (std::vector< data::NodeFragment > fragments) override |
| Append several fragments in one batch. | |
| a11::Future< data::NodeFragment > | ClearData (std::uint32_t seq) override |
| Erase the payload of the fragment at a sequence number while keeping its slot. | |
| a11::Future< std::uint32_t > | GetSeqForArrivalOrder (std::uint64_t arrival_order) override |
| Translate an arrival order into the sequence number of that fragment. | |
| a11::Future< std::optional< std::uint32_t > > | GetFinalSeq () override |
| Get the sequence number explicitly marked as the final fragment. | |
| a11::Future< absl::Status > | CloseWritesWithStatus (absl::Status status, bool return_status_if_already_closed) override |
| Seal the store against further writes with a terminal status. | |
| a11::Future< size_t > | Size () override |
| Get the number of fragments currently in the store. | |
| absl::StatusOr< std::string > | GetId () const override |
| Get the store's node identifier. | |
| a11::Task | Initialize () |
| Ensure that the metadata hash exists, without writing chunk data. | |
| a11::Future< RedisChunkStoreMetadata > | GetMetadata () |
| Read all node-level metadata without iterating over stream entries. | |
| std::shared_ptr< redis::Client > | client () const |
| Return the shared Redis client used for commands and subscriptions. | |
| const RedisChunkStoreOptions & | options () const |
| Return the validated storage policy captured at construction. | |
| const RedisChunkStoreKeys & | keys () const |
| Return the sharding-safe key set owned by this node. | |
| RedisChunkStore (ConstructorToken, std::string node_id, std::shared_ptr< redis::Client > client, RedisChunkStoreOptions options, RedisChunkStoreKeys keys) | |
| a11::Future< absl::Status > | CloseWritesWithStatus (absl::Status status) |
| Seal the store against further writes with a terminal status. | |
| virtual a11::Future< absl::Status > | CloseWritesWithStatus (absl::Status status, bool return_status_if_already_closed)=0 |
| Seal the store against further writes with a terminal status. | |
| a11::Future< data::NodeFragment > | Get (std::uint32_t seq) |
| Get the fragment at a sequence number, waiting indefinitely. | |
| virtual a11::Future< data::NodeFragment > | Get (std::uint32_t seq, absl::Time deadline)=0 |
| Get the fragment stored at a sequence number. | |
| a11::Future< data::NodeFragment > | GetByArrivalOrder (std::uint64_t arrival_order) |
| Get a fragment by arrival order, waiting indefinitely. | |
| virtual a11::Future< data::NodeFragment > | GetByArrivalOrder (std::uint64_t arrival_order, absl::Time deadline)=0 |
| Get the fragment identified by the order in which it arrived, rather than by its sequence number. | |
| a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next () |
| Get the next logical-sequence fragment, waiting indefinitely. | |
| a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next (absl::Time deadline) |
| Get the next logical-sequence fragment before a deadline. | |
| virtual a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next (absl::Time deadline, size_t limit)=0 |
Get up to limit fragments from the shared logical-sequence cursor. | |
Public Member Functions inherited from a11::stores::ChunkStore | |
| virtual | ~ChunkStore ()=default |
| a11::Future< data::NodeFragment > | Get (std::uint32_t seq) |
| Get the fragment at a sequence number, waiting indefinitely. | |
| a11::Future< data::NodeFragment > | GetByArrivalOrder (std::uint64_t arrival_order) |
| Get a fragment by arrival order, waiting indefinitely. | |
| a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next () |
| Get the next logical-sequence fragment, waiting indefinitely. | |
| a11::Future< std::vector< std::optional< data::NodeFragment > > > | Next (absl::Time deadline) |
| Get the next logical-sequence fragment before a deadline. | |
| a11::Future< absl::Status > | CloseWritesWithStatus (absl::Status status) |
| Seal the store against further writes with a terminal status. | |
Static Public Member Functions | |
| static absl::StatusOr< std::shared_ptr< RedisChunkStore > > | Create (std::string node_id, std::shared_ptr< redis::Client > client, RedisChunkStoreOptions options) |
| Create a store with an injected client and explicit storage policy. | |
| static absl::StatusOr< std::shared_ptr< RedisChunkStore > > | Create (std::string node_id, std::shared_ptr< redis::Client > client) |
| Create a store with an injected client and environment/default policy. | |
| static absl::StatusOr< std::shared_ptr< RedisChunkStore > > | Create (std::string node_id) |
| Create with the process-global, environment-configured Redis client. | |
A persistent, multi-process ChunkStore backed by Redis Streams.
Every key for a node contains the same Redis Cluster hash tag, so each Lua operation is valid on both standalone and sharded Redis deployments. The metadata hash exposes node identity, closure, final sequence, counts and cursors without walking the stream. Chunks up to the configured threshold are inline stream fields; larger encoded chunks live in a separate blob hash and the stream records storage=redis plus a reference. The storage-kind field reserves s3 for a future S3-compatible blob implementation.
Writes, closure and tombstoning are validated and committed by one Lua invocation. A getter first performs an optimistic atomic lookup. Only when it must wait does it subscribe and recheck state before waiting on a broadcast generation, eliminating the lookup/notification race without a blocking Redis command or a fiber parked on a foreign lock.
|
overridedefault |
|
inline |
|
overridevirtual |
Erase the payload of the fragment at a sequence number while keeping its slot.
Used to reclaim memory for fragments that have already been consumed without disturbing the sequence numbering.
| seq | The sequence number whose payload should be cleared. |
Implements a11::stores::ChunkStore.
|
inline |
Return the shared Redis client used for commands and subscriptions.
|
inline |
Seal the store against further writes with a terminal status.
Convenience overload that does not return the previously recorded status if the store is already closed.
| status | The terminal status to record; readers awaiting Next() are released. |
|
overridevirtual |
Seal the store against further writes with a terminal status.
Once closed, readers blocked on Next() are released. Call this when a producer has finished (or failed).
| status | The terminal status to record. |
| return_status_if_already_closed | When true, a second close resolves with the status recorded by the first close instead of overwriting it. |
Implements a11::stores::ChunkStore.
|
virtual |
Seal the store against further writes with a terminal status.
Once closed, readers blocked on Next() are released. Call this when a producer has finished (or failed).
| status | The terminal status to record. |
| return_status_if_already_closed | When true, a second close resolves with the status recorded by the first close instead of overwriting it. |
Implements a11::stores::ChunkStore.
|
static |
Create with the process-global, environment-configured Redis client.
|
static |
Create a store with an injected client and environment/default policy.
|
static |
Create a store with an injected client and explicit storage policy.
|
inline |
Get the fragment at a sequence number, waiting indefinitely.
Convenience overload equivalent to Get() with an infinite deadline.
| seq | The sequence number of the fragment to retrieve. |
|
overridevirtual |
Get the fragment stored at a sequence number.
As storage may be non-local, errors are surfaced through the resolved fragment/status. Correct implementations resolve with an error rather than blocking forever once the fragment can no longer arrive (e.g. writes were closed with a smaller final sequence number).
| seq | The sequence number of the fragment to retrieve. |
| deadline | The absolute time after which the wait gives up. |
Implements a11::stores::ChunkStore.
|
virtual |
Get the fragment stored at a sequence number.
As storage may be non-local, errors are surfaced through the resolved fragment/status. Correct implementations resolve with an error rather than blocking forever once the fragment can no longer arrive (e.g. writes were closed with a smaller final sequence number).
| seq | The sequence number of the fragment to retrieve. |
| deadline | The absolute time after which the wait gives up. |
Implements a11::stores::ChunkStore.
|
inline |
Get a fragment by arrival order, waiting indefinitely.
Convenience overload equivalent to GetByArrivalOrder() with an infinite deadline.
| arrival_order | The zero-based rank in which the fragment arrived in the store. |
|
overridevirtual |
Get the fragment identified by the order in which it arrived, rather than by its sequence number.
Useful for replaying fragments in ingestion order regardless of the sequence numbers assigned to them.
| arrival_order | The zero-based rank in which the fragment arrived in the store. |
| deadline | The absolute time after which the wait gives up. |
Implements a11::stores::ChunkStore.
|
virtual |
Get the fragment identified by the order in which it arrived, rather than by its sequence number.
Useful for replaying fragments in ingestion order regardless of the sequence numbers assigned to them.
| arrival_order | The zero-based rank in which the fragment arrived in the store. |
| deadline | The absolute time after which the wait gives up. |
Implements a11::stores::ChunkStore.
|
overridevirtual |
Get the sequence number explicitly marked as the final fragment.
Finality and write closure are separate state transitions. A producer may mark a fragment final before closing the store, and CloseWritesWithStatus() does not invent a final fragment.
Implements a11::stores::ChunkStore.
|
overridevirtual |
Get the store's node identifier.
Implements a11::stores::ChunkStore.
| a11::Future< RedisChunkStoreMetadata > a11::stores::RedisChunkStore::GetMetadata | ( | ) |
Read all node-level metadata without iterating over stream entries.
|
overridevirtual |
Translate an arrival order into the sequence number of that fragment.
| arrival_order | The zero-based rank in which the fragment arrived in the store. |
Implements a11::stores::ChunkStore.
| a11::Task a11::stores::RedisChunkStore::Initialize | ( | ) |
Ensure that the metadata hash exists, without writing chunk data.
|
inline |
Return the sharding-safe key set owned by this node.
|
inline |
Get the next logical-sequence fragment, waiting indefinitely.
Convenience overload equivalent to Next() with an infinite deadline and a limit of one.
|
inline |
Get the next logical-sequence fragment before a deadline.
Convenience overload equivalent to Next() with a limit of one.
| deadline | The absolute time after which the wait gives up. |
|
overridevirtual |
Get up to limit fragments from the shared logical-sequence cursor.
Next() advances through sequence numbers 0, 1, 2, and so on. It waits at a gap rather than switching to ingestion order; use GetByArrivalOrder() for that view. After the final sequence or a clean write closure, the result includes a nullopt end sentinel. Call repeatedly to follow the store as it grows.
| deadline | The absolute time after which the wait gives up. |
| limit | The maximum number of fragments to return in one call. |
limit data fragments; a clean end may append a nullopt sentinel. Implements a11::stores::ChunkStore.
|
virtual |
Get up to limit fragments from the shared logical-sequence cursor.
Next() advances through sequence numbers 0, 1, 2, and so on. It waits at a gap rather than switching to ingestion order; use GetByArrivalOrder() for that view. After the final sequence or a clean write closure, the result includes a nullopt end sentinel. Call repeatedly to follow the store as it grows.
| deadline | The absolute time after which the wait gives up. |
| limit | The maximum number of fragments to return in one call. |
limit data fragments; a clean end may append a nullopt sentinel. Implements a11::stores::ChunkStore.
|
inline |
Return the validated storage policy captured at construction.
|
overridevirtual |
Append a single fragment to the log.
| fragment | The fragment to append. |
Implements a11::stores::ChunkStore.
|
overridevirtual |
Append several fragments in one batch.
Preferred over repeated Put() calls when many fragments are emitted at once, to reduce round-trips.
| fragments | The fragments to append, in order. |
Implements a11::stores::ChunkStore.
|
overridevirtual |
Get the number of fragments currently in the store.
Implements a11::stores::ChunkStore.