Skip to content

CronTickerOccurrenceEntity<TCronTicker>

Represents a single execution occurrence of a CronTicker.

Type Definition

csharp
public class CronTickerOccurrenceEntity<TCronTicker> 
    where TCronTicker : CronTickerEntity
{
    public Guid Id { get; set; }
    public Guid CronTickerId { get; set; }
    public TickerStatus Status { get; set; }
    public DateTime ExecutionTime { get; set; }
    public DateTime? ExecutedAt { get; set; }
    public long ElapsedTime { get; set; }
    public int RetryCount { get; set; }
    public string LockHolder { get; set; }
    public DateTime? LockedAt { get; set; }
    public string ExceptionMessage { get; set; }
    public string SkippedReason { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }
    public TCronTicker CronTicker { get; set; }
}

Properties

PropertyTypeDescription
IdGuidUnique occurrence identifier
CronTickerIdGuidParent CronTicker ID
StatusTickerStatusExecution status (Idle, Queued, InProgress, Done, Failed, etc.)
ExecutionTimeDateTimeScheduled execution time
ExecutedAtDateTime?Actual execution time
ElapsedTimelongExecution duration in milliseconds
RetryCountintRetry attempts made
LockHolderstringNode that locked this occurrence
LockedAtDateTime?Lock timestamp
ExceptionMessagestringException details if failed
SkippedReasonstringSkip reason if skipped
CreatedAtDateTimeCreation timestamp
UpdatedAtDateTimeLast update timestamp
CronTickerTCronTickerNavigation property to parent CronTicker

Notes

  • Occurrences are created automatically when a CronTicker should execute
  • Each occurrence tracks individual execution status
  • Occurrences can be queried to view execution history
  • Multiple occurrences can exist for the same CronTicker (past, present, future)

Querying Occurrences

When using Entity Framework Core:

csharp
// Get all occurrences for a CronTicker
var occurrences = await _context.Set<CronTickerOccurrenceEntity>()
    .Where(o => o.CronTickerId == cronTickerId)
    .OrderByDescending(o => o.ExecutionTime)
    .Take(10)
    .ToListAsync();

// Get failed occurrences
var failedOccurrences = await _context.Set<CronTickerOccurrenceEntity>()
    .Where(o => o.Status == TickerStatus.Failed)
    .ToListAsync();

Relationship

CronTickerEntity
└── CronTickerOccurrenceEntity (created for each execution)
    └── CronTickerOccurrenceEntity (next execution)
    └── ...

See Also

Built by Albert Kunushevci