InMemoryRetentionPolicyStore
AgentPrism.Core.dllThe default implementation that keeps retention policies and run history in process memory.
public sealed class InMemoryRetentionPolicyStore : IRetentionPolicyStoreInheritance
Section titled “Inheritance”object ← InMemoryRetentionPolicyStore
Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”For single-process deployments and tests. UsePostgreSql,
UseSqlServer, or UseSqlite replaces it with a SQL implementation.
Constructors
Section titled “Constructors”InMemoryRetentionPolicyStore()
Section titled “ InMemoryRetentionPolicyStore()”public InMemoryRetentionPolicyStore()Methods
Section titled “Methods”AppendRunProgressAsync(Guid, long, long, CancellationToken)
Section titled “ AppendRunProgressAsync(Guid, long, long, CancellationToken)”Increments an in-progress run’s counters. Called after each batch.
public ValueTask AppendRunProgressAsync(Guid runId, long deletedDelta, long archivedDelta, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”runId Guid
The run identifier.
deletedDelta long
The number of rows deleted in this batch.
archivedDelta long
The number of rows archived in this batch.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The completion task.
CompleteRunAsync(Guid, DateTimeOffset, string?, CancellationToken)
Section titled “ CompleteRunAsync(Guid, DateTimeOffset, string?, CancellationToken)”Finalizes a run.
public ValueTask CompleteRunAsync(Guid runId, DateTimeOffset completedAt, string? errorMessage, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”runId Guid
The run identifier.
completedAt DateTimeOffset
The completion time (UTC).
errorMessage string?
The error message; null if successful.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The completion task.
CreateRunAsync(RetentionRun, CancellationToken)
Section titled “ CreateRunAsync(RetentionRun, CancellationToken)”Opens a new cleanup run.
public ValueTask<RetentionRun> CreateRunAsync(RetentionRun run, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”run RetentionRun
The starting record. RetentionRun.CompletedAt is ignored.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The created record.
DeletePolicyAsync(string, string, CancellationToken)
Section titled “ DeletePolicyAsync(string, string, CancellationToken)”Deletes a policy.
public ValueTask<bool> DeletePolicyAsync(string tenantId, string target, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
target string
The target name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the delete happened.
GetPolicyAsync(string, string, CancellationToken)
Section titled “ GetPolicyAsync(string, string, CancellationToken)”Looks up a single target’s policy within the tenant, falling back to the "*" tenant-wide policy.
public ValueTask<RetentionPolicy?> GetPolicyAsync(string tenantId, string target, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
target string
The target name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The policy; null if none exists at either level.
ListPoliciesAsync(string, CancellationToken)
Section titled “ ListPoliciesAsync(string, CancellationToken)”Lists all of a tenant’s policies (and the "*" tenant-wide ones).
public ValueTask<IReadOnlyList<RetentionPolicy>> ListPoliciesAsync(string tenantId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<RetentionPolicy>>
The policies.
ListRunsAsync(string, string?, int, int, CancellationToken)
Section titled “ ListRunsAsync(string, string?, int, int, CancellationToken)”Lists a tenant’s run history. The newest record is returned first.
public ValueTask<IReadOnlyList<RetentionRun>> ListRunsAsync(string tenantId, string? target, int skip, int take, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
target string?
Fetches only this target’s runs; all if null.
skip int
The number of records to skip.
take int
The maximum number of records to fetch.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<RetentionRun>>
The records.
SavePolicyAsync(RetentionPolicy, CancellationToken)
Section titled “ SavePolicyAsync(RetentionPolicy, CancellationToken)”Creates or updates a policy.
public ValueTask<RetentionPolicy> SavePolicyAsync(RetentionPolicy policy, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”policy RetentionPolicy
The policy.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The saved policy.