Zum Hauptinhalt springen

IArchiveRuntimeStore

Namespace: Meshmakers.Octo.Runtime.Contracts.StreamData

Abstracts the persistence operations on CkArchive entities required by IArchiveLifecycleService. Decouples the lifecycle state machine from any particular runtime repository implementation (Mongo today, possibly others later) and from the generated CkArchive class itself, so the service stays in Runtime.Engine without taking a hard dependency on the StreamData CK model package.

public interface IArchiveRuntimeStore

Methods​

GetAsync(OctoObjectId)​

Reads the current state of the archive identified by archiveRtId, or null if no such entity exists (or has been soft-deleted).

Task<ArchiveSnapshot> GetAsync(OctoObjectId archiveRtId)

Parameters​

archiveRtId OctoObjectId

Returns​

Task<ArchiveSnapshot>

SetStatusAsync(OctoObjectId, CkArchiveStatus)​

Writes a new CkArchiveStatus on the archive entity. Implementations are responsible for any validation hooks (concept §10) and for emitting the corresponding status-transition event (§14) only if the lifecycle service hasn't already done so via IArchiveAuditTrail. A store that keeps the status reason clears Archive.StatusReason and Archive.HiddenColumns with this write.

Task SetStatusAsync(OctoObjectId archiveRtId, CkArchiveStatus newStatus)

Parameters​

archiveRtId OctoObjectId

newStatus CkArchiveStatus

Returns​

Task

SetStatusAsync(OctoObjectId, CkArchiveStatus, String, IReadOnlyList<String>)​

Writes a new CkArchiveStatus together with its reason: Archive.StatusReason and Archive.HiddenColumns (the ingested column paths that reached a Hidden attribute). A null reason and an empty list clear both, which every transition other than the one to CkArchiveStatus.Failed does. The default implementation writes the status only (stores built in older versions keep no reason).

Task SetStatusAsync(OctoObjectId archiveRtId, CkArchiveStatus newStatus, string statusReason, IReadOnlyList<string> hiddenColumns)

Parameters​

archiveRtId OctoObjectId

newStatus CkArchiveStatus

statusReason String

hiddenColumns IReadOnlyList<String>

Returns​

Task

ArchiveEntityAsync(OctoObjectId)​

Soft-deletes the archive entity by setting rtState = Archived. The Crate table is dropped separately by the lifecycle service via IStreamDataRepository.

Task ArchiveEntityAsync(OctoObjectId archiveRtId)

Parameters​

archiveRtId OctoObjectId

Returns​

Task

EnumerateAsync()​

Enumerates every non-soft-deleted CkArchive entity in the tenant. Used by the startup reconciliation job (concept §11) to compare Mongo state against CrateDB reality. Order is implementation-defined; callers must not rely on it.

IAsyncEnumerable<ArchiveSnapshot> EnumerateAsync()

Returns​

IAsyncEnumerable<ArchiveSnapshot>

AddComputedColumnAsync(OctoObjectId, CkArchiveColumnSpec)​

Appends a computed column to the archive's column set. The caller supplies the column already carrying its initial CkArchiveColumnSpec.ComputedState (normally ComputedColumnState.Pending for an add to a live archive). Used by the computed-column lifecycle on IArchiveLifecycleService.

Task AddComputedColumnAsync(OctoObjectId archiveRtId, CkArchiveColumnSpec column)

Parameters​

archiveRtId OctoObjectId

column CkArchiveColumnSpec

Returns​

Task

AddIngestedColumnAsync(OctoObjectId, CkArchiveColumnSpec)​

Appends an ingested column (a CK attribute path, no formula) to the archive's column set. Called by IArchiveLifecycleService.AddArchiveColumnAsync(OctoObjectId, String, Boolean, CancellationToken) only after the physical column exists, so the definition never names a column the table lacks. The default appends through IArchiveRuntimeStore.AddComputedColumnAsync(OctoObjectId, CkArchiveColumnSpec), which stores the column as given.

Task AddIngestedColumnAsync(OctoObjectId archiveRtId, CkArchiveColumnSpec column)

Parameters​

archiveRtId OctoObjectId

column CkArchiveColumnSpec

Returns​

Task

SetComputedColumnStateAsync(OctoObjectId, String, ComputedColumnState)​

Sets the engine-managed lifecycle ComputedColumnState of the computed column named name on the archive. This single write is the atomic switch for the add flow: while the state is Pending / Backfilling the read path hides the column; flipping it to Active exposes the backfilled values.

Task SetComputedColumnStateAsync(OctoObjectId archiveRtId, string name, ComputedColumnState state)

Parameters​

archiveRtId OctoObjectId

name String

state ComputedColumnState

Returns​

Task

RemoveComputedColumnAsync(OctoObjectId, String)​

Removes the computed column named name from the archive's column set . The physical CrateDB column is left in place (a harmless nullable orphan the read path no longer projects); a later re-add of the same name reuses it.

Task RemoveComputedColumnAsync(OctoObjectId archiveRtId, string name)

Parameters​

archiveRtId OctoObjectId

name String

Returns​

Task

RemoveIngestedColumnsAsync(OctoObjectId, IReadOnlyCollection<String>)​

Removes the ingested columns with the given paths (case-insensitive) from the archive's column set (IArchiveLifecycleService.RedactHiddenColumnsAsync(OctoObjectId)). Called only after the physical columns were dropped, so the definition never names a column the table lacks. Computed columns are never removed here. The default implementation throws NotSupportedException.

Task RemoveIngestedColumnsAsync(OctoObjectId archiveRtId, IReadOnlyCollection<string> columnPaths)

Parameters​

archiveRtId OctoObjectId

columnPaths IReadOnlyCollection<String>

Returns​

Task

SetPendingFormulaAsync(OctoObjectId, String, String)​

Sets the transient PendingFormula marker on a computed column, starting a formula change: the column keeps serving its current formula while ingest begins dual-writing the pending formula into the versioned physical column. The column stays Active throughout.

Task SetPendingFormulaAsync(OctoObjectId archiveRtId, string name, string pendingFormula)

Parameters​

archiveRtId OctoObjectId

name String

pendingFormula String

Returns​

Task

SwapComputedColumnFormulaAsync(OctoObjectId, String, String, Int32)​

Atomically swaps a computed column to its new formula once the backfill completes: sets Formula = newFormula, ComputedVersion = newVersion, and clears PendingFormula in one write. After this the read path resolves the column to the new versioned physical column.

Task SwapComputedColumnFormulaAsync(OctoObjectId archiveRtId, string name, string newFormula, int newVersion)

Parameters​

archiveRtId OctoObjectId

name String

newFormula String

newVersion Int32

Returns​

Task

ClearPendingFormulaAsync(OctoObjectId, String)​

Clears the PendingFormula marker without swapping, reverting a failed formula change: the column keeps its previous formula / version and ingest stops dual-writing. The orphaned pending physical column is left in place.

Task ClearPendingFormulaAsync(OctoObjectId archiveRtId, string name)

Parameters​

archiveRtId OctoObjectId

name String

Returns​

Task