InMemoryJobScheduleStore
AgentPrism.Core.dllA store that keeps schedule definitions in process memory.
public sealed class InMemoryJobScheduleStore : IJobScheduleStoreInheritance
Section titled “Inheritance”object ← InMemoryJobScheduleStore
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”Limits: process lifetime and a single node. Use
AgentPrism.PostgreSql in production.
Constructors
Section titled “Constructors”InMemoryJobScheduleStore()
Section titled “ InMemoryJobScheduleStore()”public InMemoryJobScheduleStore()Methods
Section titled “Methods”DeleteAsync(string, string, CancellationToken)
Section titled “ DeleteAsync(string, string, CancellationToken)”Deletes the schedule.
public ValueTask<bool> DeleteAsync(string tenantId, string name, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The schedule name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the delete happened.
GetAsync(string, string, CancellationToken)
Section titled “ GetAsync(string, string, CancellationToken)”Fetches the schedule with the given name.
public ValueTask<JobSchedule?> GetAsync(string tenantId, string name, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The schedule name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The schedule; null if it does not exist.
ListAsync(string, CancellationToken)
Section titled “ ListAsync(string, CancellationToken)”Lists all of a tenant’s schedules, by name.
public ValueTask<IReadOnlyList<JobSchedule>> ListAsync(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<JobSchedule>>
The schedules.
ListDueAsync(DateTimeOffset, CancellationToken)
Section titled “ ListDueAsync(DateTimeOffset, CancellationToken)”Lists the schedules of every tenant that are due to run
(NextRunAt <= asOfUtc), enabled, and carry a cron expression.
public ValueTask<IReadOnlyList<JobSchedule>> ListDueAsync(DateTimeOffset asOfUtc, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”asOfUtc DateTimeOffset
The comparison moment (UTC).
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<JobSchedule>>
The due schedules.
SaveAsync(JobSchedule, CancellationToken)
Section titled “ SaveAsync(JobSchedule, CancellationToken)”Creates or updates the schedule (name + tenant is unique).
public ValueTask<JobSchedule> SaveAsync(JobSchedule schedule, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”schedule JobSchedule
The schedule to save.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The saved schedule.
TryClaimNextRunAsync(Guid, DateTimeOffset, DateTimeOffset, DateTimeOffset, CancellationToken)
Section titled “ TryClaimNextRunAsync(Guid, DateTimeOffset, DateTimeOffset, DateTimeOffset, CancellationToken)”Tries to atomically advance a schedule’s JobSchedule.NextRunAt field (compare-and-swap).
public ValueTask<bool> TryClaimNextRunAsync(Guid scheduleId, DateTimeOffset expectedNextRunAt, DateTimeOffset newNextRunAt, DateTimeOffset ranAt, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”scheduleId Guid
The schedule identifier.
expectedNextRunAt DateTimeOffset
The expected current value. If another instance has already advanced it, the value does not match and the operation fails — this is how two overlapping scheduling triggers are prevented.
newNextRunAt DateTimeOffset
The new next-run time.
ranAt DateTimeOffset
The time this trigger happened (UTC).
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the claim succeeded.